|
Packit |
5e46da |
/*
|
|
Packit |
5e46da |
* This file is part of libbluray
|
|
Packit |
5e46da |
* Copyright (C) 2010-2017 Petri Hintukainen <phintuka@users.sourceforge.net>
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* This library is free software; you can redistribute it and/or
|
|
Packit |
5e46da |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit |
5e46da |
* License as published by the Free Software Foundation; either
|
|
Packit |
5e46da |
* version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* This library is distributed in the hope that it will be useful,
|
|
Packit |
5e46da |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
5e46da |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
5e46da |
* Lesser General Public License for more details.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit |
5e46da |
* License along with this library. If not, see
|
|
Packit |
5e46da |
* <http://www.gnu.org/licenses/>.
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
#if !defined(_BD_REGISTER_H_)
|
|
Packit |
5e46da |
#define _BD_REGISTER_H_
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
#include "util/attributes.h"
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
#include <stdint.h>
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
#define BD_PSR_COUNT 128
|
|
Packit |
5e46da |
#define BD_GPR_COUNT 4096
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/*
|
|
Packit |
5e46da |
* Player Status Registers
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
typedef enum {
|
|
Packit |
5e46da |
PSR_IG_STREAM_ID = 0,
|
|
Packit |
5e46da |
PSR_PRIMARY_AUDIO_ID = 1,
|
|
Packit |
5e46da |
PSR_PG_STREAM = 2, /* PG TextST and PIP PG TextST stream number */
|
|
Packit |
5e46da |
PSR_ANGLE_NUMBER = 3, /* 1..N */
|
|
Packit |
5e46da |
PSR_TITLE_NUMBER = 4, /* 1..N (0 = top menu, 0xffff = first play) */
|
|
Packit |
5e46da |
PSR_CHAPTER = 5, /* 1..N (0xffff = invalid) */
|
|
Packit |
5e46da |
PSR_PLAYLIST = 6, /* playlist file name number */
|
|
Packit |
5e46da |
PSR_PLAYITEM = 7, /* 0..N-1 (playitem_id) */
|
|
Packit |
5e46da |
PSR_TIME = 8, /* presetation time */
|
|
Packit |
5e46da |
PSR_NAV_TIMER = 9,
|
|
Packit |
5e46da |
PSR_SELECTED_BUTTON_ID = 10,
|
|
Packit |
5e46da |
PSR_MENU_PAGE_ID = 11,
|
|
Packit |
5e46da |
PSR_STYLE = 12,
|
|
Packit |
5e46da |
PSR_PARENTAL = 13,
|
|
Packit |
5e46da |
PSR_SECONDARY_AUDIO_VIDEO = 14,
|
|
Packit |
5e46da |
PSR_AUDIO_CAP = 15,
|
|
Packit |
5e46da |
PSR_AUDIO_LANG = 16,
|
|
Packit |
5e46da |
PSR_PG_AND_SUB_LANG = 17,
|
|
Packit |
5e46da |
PSR_MENU_LANG = 18,
|
|
Packit |
5e46da |
PSR_COUNTRY = 19,
|
|
Packit |
5e46da |
PSR_REGION = 20,
|
|
Packit |
5e46da |
PSR_OUTPUT_PREFER = 21,
|
|
Packit |
5e46da |
PSR_3D_STATUS = 22,
|
|
Packit |
5e46da |
PSR_DISPLAY_CAP = 23,
|
|
Packit |
5e46da |
PSR_3D_CAP = 24,
|
|
Packit |
5e46da |
PSR_UHD_CAP = 25,
|
|
Packit |
5e46da |
PSR_UHD_DISPLAY_CAP = 26,
|
|
Packit |
5e46da |
PSR_UHD_HDR_PREFER = 27,
|
|
Packit |
5e46da |
PSR_UHD_SDR_CONV_PREFER = 28,
|
|
Packit |
5e46da |
PSR_VIDEO_CAP = 29,
|
|
Packit |
5e46da |
PSR_TEXT_CAP = 30, /* text subtitles */
|
|
Packit |
5e46da |
PSR_PROFILE_VERSION = 31, /* player profile and version */
|
|
Packit |
5e46da |
PSR_BACKUP_PSR4 = 36,
|
|
Packit |
5e46da |
PSR_BACKUP_PSR5 = 37,
|
|
Packit |
5e46da |
PSR_BACKUP_PSR6 = 38,
|
|
Packit |
5e46da |
PSR_BACKUP_PSR7 = 39,
|
|
Packit |
5e46da |
PSR_BACKUP_PSR8 = 40,
|
|
Packit |
5e46da |
PSR_BACKUP_PSR10 = 42,
|
|
Packit |
5e46da |
PSR_BACKUP_PSR11 = 43,
|
|
Packit |
5e46da |
PSR_BACKUP_PSR12 = 44,
|
|
Packit |
5e46da |
/* 48-61: caps for characteristic text subtitle */
|
|
Packit |
5e46da |
} bd_psr_idx;
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
typedef struct bd_registers_s BD_REGISTERS;
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* Initialize registers
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @return allocated BD_REGISTERS object with default values
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
BD_PRIVATE BD_REGISTERS *bd_registers_init(void);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* Free BD_REGISTERS object
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param registers BD_REGISTERS object
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
BD_PRIVATE void bd_registers_free(BD_REGISTERS *);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/*
|
|
Packit |
5e46da |
* GPR (general-purprose register) access
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* Read value of general-purprose register
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param registers BD_REGISTERS object
|
|
Packit |
5e46da |
* @param reg register number
|
|
Packit |
5e46da |
* @return value stored in register, -1 on error (invalid register number)
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
uint32_t bd_gpr_read(BD_REGISTERS *, unsigned int reg);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* Write to general-purprose register
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param registers BD_REGISTERS object
|
|
Packit |
5e46da |
* @param reg register number
|
|
Packit |
5e46da |
* @param val new value for register
|
|
Packit |
5e46da |
* @return 0 on success, -1 on error (invalid register number)
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
int bd_gpr_write(BD_REGISTERS *, unsigned int reg, uint32_t val);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/*
|
|
Packit |
5e46da |
* PSR (player status / setting register) access
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* Read value of player status/setting register
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param registers BD_REGISTERS object
|
|
Packit |
5e46da |
* @param reg register number
|
|
Packit |
5e46da |
* @return value stored in register, -1 on error (invalid register number)
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
uint32_t bd_psr_read(BD_REGISTERS *, unsigned int reg);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* Write to player status register.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* Writing to player setting registers will fail.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param registers BD_REGISTERS object
|
|
Packit |
5e46da |
* @param reg register number
|
|
Packit |
5e46da |
* @param val new value for register
|
|
Packit |
5e46da |
* @return 0 on success, -1 on error (invalid register number)
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
int bd_psr_write(BD_REGISTERS *, unsigned int reg, uint32_t val);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* Atomically change bits in player status register.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* Replace selected bits of player status register.
|
|
Packit |
5e46da |
* New value for PSR is (CURRENT_PSR_VALUE & ~mask) | (val & mask)
|
|
Packit |
5e46da |
* Writing to player setting registers will fail.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param registers BD_REGISTERS object
|
|
Packit |
5e46da |
* @param reg register number
|
|
Packit |
5e46da |
* @param val new value for register
|
|
Packit |
5e46da |
* @param mask bit mask. bits to be written are set to 1.
|
|
Packit |
5e46da |
* @return 0 on success, -1 on error (invalid register number)
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
BD_PRIVATE int bd_psr_write_bits(BD_REGISTERS *, unsigned int reg, uint32_t val, uint32_t mask);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* Write to any PSR, including player setting registers.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* This should be called only by the application.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param registers BD_REGISTERS object
|
|
Packit |
5e46da |
* @param reg register number
|
|
Packit |
5e46da |
* @param val new value for register
|
|
Packit |
5e46da |
* @return 0 on success, -1 on error (invalid register number)
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
BD_PRIVATE int bd_psr_setting_write(BD_REGISTERS *, unsigned int reg, uint32_t val);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* Lock PSRs for atomic read-modify-write operation
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param registers BD_REGISTERS object
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
BD_PRIVATE void bd_psr_lock(BD_REGISTERS *);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* Unlock PSRs
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param registers BD_REGISTERS object
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
BD_PRIVATE void bd_psr_unlock(BD_REGISTERS *);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* Save player state
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* Copy values of registers 4-8 and 10-12 to backup registers 36-40 and 42-44.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param registers BD_REGISTERS object
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
BD_PRIVATE void bd_psr_save_state(BD_REGISTERS *);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* Restore player state
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* Restore registers 4-8 and 10-12 from backup registers 36-40 and 42-44.
|
|
Packit |
5e46da |
* Initialize backup registers to default values.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param registers BD_REGISTERS object
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
BD_PRIVATE void bd_psr_restore_state(BD_REGISTERS *);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* Reset backup registers
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* Initialize backup registers 36-40 and 42-44 to default values.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param registers BD_REGISTERS object
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
BD_PRIVATE void bd_psr_reset_backup_registers(BD_REGISTERS *);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/*
|
|
Packit |
5e46da |
* Events when PSR value is changed
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/* event types */
|
|
Packit |
5e46da |
#define BD_PSR_SAVE 1 /* backup player state. Single event, psr_idx and values undefined */
|
|
Packit |
5e46da |
#define BD_PSR_WRITE 2 /* write, value unchanged */
|
|
Packit |
5e46da |
#define BD_PSR_CHANGE 3 /* write, value changed */
|
|
Packit |
5e46da |
#define BD_PSR_RESTORE 4 /* restore backup values */
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/* event data */
|
|
Packit |
5e46da |
typedef struct {
|
|
Packit |
5e46da |
unsigned ev_type; /* event type */
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
unsigned psr_idx; /* register index */
|
|
Packit |
5e46da |
uint32_t old_val; /* old value of register */
|
|
Packit |
5e46da |
uint32_t new_val; /* new value of register */
|
|
Packit |
5e46da |
} BD_PSR_EVENT;
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* Register callback function
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* Function is called every time PSR value changes.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param registers BD_REGISTERS object
|
|
Packit |
5e46da |
* @param callback callback function pointer
|
|
Packit |
5e46da |
* @param handle application-specific handle that is provided to callback function as first parameter
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
void bd_psr_register_cb(BD_REGISTERS *, void (*callback)(void*,BD_PSR_EVENT*), void *cb_handle);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* Unregister callback function
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param registers BD_REGISTERS object
|
|
Packit |
5e46da |
* @param callback callback function to unregister
|
|
Packit |
5e46da |
* @param handle application-specific handle that was used when callback was registered
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
void bd_psr_unregister_cb(BD_REGISTERS *, void (*callback)(void*,BD_PSR_EVENT*), void *cb_handle);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
BD_PRIVATE int psr_init_3D(BD_REGISTERS *, int initial_mode, int force);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* Initialize registers for profile 6 (UHD) playback.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* Profiles 5 (3D) and 6 (UHD) can't be enabld at the same time.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param registers BD_REGISTERS object
|
|
Packit |
5e46da |
* @return 0 on success, -1 on error (invalid state)
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
BD_PRIVATE int psr_init_UHD(BD_REGISTERS *, int force);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/*
|
|
Packit |
5e46da |
* save / restore registers between playback sessions
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* When state is restored, restore events will be generated and playback state is restored.
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
BD_PRIVATE void registers_save(BD_REGISTERS *p, uint32_t *psr, uint32_t *gpr);
|
|
Packit |
5e46da |
BD_PRIVATE void registers_restore(BD_REGISTERS *p, const uint32_t *psr, const uint32_t *gpr);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
#endif /* _BD_REGISTER_H_ */
|