更新UCD-API库及文档
This commit is contained in:
83
UniTAP/dev/ports/modules/earc/earc_tx.py
Normal file
83
UniTAP/dev/ports/modules/earc/earc_tx.py
Normal file
@@ -0,0 +1,83 @@
|
||||
from ctypes import c_ubyte
|
||||
|
||||
from UniTAP.dev.ports.modules.ag.earc import AudioGeneratorEARC
|
||||
from UniTAP.dev.modules.memory_manager import MemoryManager
|
||||
from UniTAP.libs.lib_tsi.tsi_io import PortIO
|
||||
|
||||
import UniTAP.libs.lib_tsi.tsi_private_types as p_ci
|
||||
import UniTAP.libs.lib_tsi.tsi_types as ci
|
||||
|
||||
from .earc_types import EarcControl, EarcMode, EarcStatus, EarcState, EarcHearthbeatState, EarcRxStatus
|
||||
|
||||
class EarcTx:
|
||||
__MAX_EARC_EDID_SIZE = 128
|
||||
|
||||
def __init__(self, port_io: PortIO, memory_manager: MemoryManager) -> None:
|
||||
self.__io = port_io
|
||||
self.__earc_ag = AudioGeneratorEARC(port_io, memory_manager)
|
||||
self.__control = self.__io.get(ci.TSI_HDRX_EARC_CTRL, EarcControl)[1]
|
||||
|
||||
def configure(self, mode: EarcMode, latency: int, bypass: bool = False) -> None:
|
||||
self.__control.mode = mode
|
||||
self.__control.bypass = bypass
|
||||
self.__apply_control()
|
||||
self.__set_audio_latency(latency)
|
||||
|
||||
def get_status(self) -> EarcStatus:
|
||||
"""
|
||||
Get eARC transmitter status.
|
||||
|
||||
Returns:
|
||||
object of `EarcStatus` type.
|
||||
"""
|
||||
return self.__io.get(ci.TSI_HDRX_EARC_STS_R, EarcStatus)[1]
|
||||
|
||||
def get_latency(self) -> int:
|
||||
"""
|
||||
Get current audio latency for eARC transmitter.
|
||||
|
||||
Returns:
|
||||
object of `int` type.
|
||||
"""
|
||||
return self.__io.get(ci.TSI_HDRX_EARC_LATENCY, int)[1]
|
||||
|
||||
def get_edid(self) -> bytearray:
|
||||
"""
|
||||
Get EDID data from eARC receiver.
|
||||
|
||||
Returns:
|
||||
object of `bytearray` type.
|
||||
"""
|
||||
result, edid_data, size = self.__io.get(ci.TSI_HDRX_EARC_EDID_DATA, c_ubyte, self.__MAX_EARC_EDID_SIZE)
|
||||
if result > 0:
|
||||
return bytearray(edid_data[:result])
|
||||
else:
|
||||
return bytearray()
|
||||
|
||||
@property
|
||||
def ag(self) -> AudioGeneratorEARC:
|
||||
"""
|
||||
Get audio generator for eARC transmitter.
|
||||
|
||||
Returns:
|
||||
object of `AudioGeneratorEARC` type.
|
||||
"""
|
||||
return self.__earc_ag
|
||||
|
||||
def __apply_control(self):
|
||||
"""
|
||||
Apply eARC control settings.
|
||||
"""
|
||||
self.__io.set(ci.TSI_HDRX_EARC_CTRL, self.__control)
|
||||
|
||||
def __set_audio_latency(self, latency: int):
|
||||
"""
|
||||
Set audio latency request for eARC transmitter.
|
||||
|
||||
Args:
|
||||
latency (int) - latency value to set
|
||||
"""
|
||||
self.__io.set(ci.TSI_HDRX_EARC_LATENCY_REQ, latency)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user