diff options
author | Tobias Jahnke <tobias.jahnke@microchip.com> | 2018-10-10 15:52:57 +0200 |
---|---|---|
committer | Tobias Jahnke <tobias.jahnke@microchip.com> | 2018-10-10 15:52:57 +0200 |
commit | b071fc0882750d28036769c56c046fe1d7ae9942 (patch) | |
tree | d33a0968eb237c4975bc879087cadff57082dd10 /MOST_UNICENS/ucs2-vol/src/device_value.cpp | |
parent | 6d4cbab774c0fa632ccdf4add35b87d0828ac765 (diff) |
4a-hal-unicens: add Fiberdyne Master Volume
Bug-AGL: SPEC-1758
As preparation before introducing UNICENS 4a plugin:
- Init volume library at first
- Add fiberdyne master volume
- Introduce commands sent by control messages
- Removes outdated controls
- Known issue: turn ALSA volume above "93" to hear some sound
Change-Id: I591c6b109a51c9da602ad08514b67c2ec573e09c
Signed-off-by: Tobias Jahnke <tobias.jahnke@microchip.com>
Diffstat (limited to 'MOST_UNICENS/ucs2-vol/src/device_value.cpp')
-rw-r--r-- | MOST_UNICENS/ucs2-vol/src/device_value.cpp | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/MOST_UNICENS/ucs2-vol/src/device_value.cpp b/MOST_UNICENS/ucs2-vol/src/device_value.cpp index 7103192..22b8dfb 100644 --- a/MOST_UNICENS/ucs2-vol/src/device_value.cpp +++ b/MOST_UNICENS/ucs2-vol/src/device_value.cpp @@ -32,11 +32,12 @@ #define CONTROL_CH_1 0x08U #define CONTROL_CH_2 0x09U -CDeviceValue::CDeviceValue(uint16_t address, DeviceValueType type, uint16_t key) +CDeviceValue::CDeviceValue(uint16_t address, DeviceValueType type, uint16_t key, bool is_i2c) { this->_is_available = false; this->_is_busy = false; this->_address = address; + this->_is_i2c = is_i2c; this->_target_value = 0x01u; this->_actual_value = 0x01u; @@ -49,7 +50,11 @@ CDeviceValue::CDeviceValue(uint16_t address, DeviceValueType type, uint16_t key) _tx_payload[0] = CONTROL_MASTER;// 7: master, 8: channel 1, 9: Channel 2 _tx_payload[1] = MUTE_VALUE_HB; //HB:Volume _tx_payload[2] = MUTE_VALUE_LB; //LB:Volume - _tx_payload_sz = 3u; + + if (type == DEVICE_VAL_FIBERDYNE_MASTER) + _tx_payload_sz = 2u; + else + _tx_payload_sz = 3u; } CDeviceValue::~CDeviceValue() @@ -60,6 +65,14 @@ void CDeviceValue::ApplyMostValue(uint8_t value, DeviceValueType type, uint8_t t { uint16_t tmp = MUTE_VALUE; + if (type == DEVICE_VAL_FIBERDYNE_MASTER) + { + tx_payload[0] = 0x00U; + tx_payload[1] = value; + + return; + } + switch (type) { case DEVICE_VAL_LEFT: @@ -75,7 +88,7 @@ void CDeviceValue::ApplyMostValue(uint8_t value, DeviceValueType type, uint8_t t tx_payload[0] = CONTROL_CH_2; break; default: - /*std::cerr << "CDeviceValue::ApplyMostValue() error matching incorrect" << std::endl;*/ + /*std::cerr << "CDeviceValue::ApplyMostValue() error matching incorrect" << std::endl;*/ case DEVICE_VAL_MASTER: tmp = (uint16_t)(0x100U + 0x2FFU - (0x2FFU * ((int32_t)value) / (0xFFU))); tx_payload[0] = CONTROL_MASTER; @@ -97,6 +110,20 @@ bool CDeviceValue::RequiresUpdate() return false; } +bool CDeviceValue::FireControlMessage(lib_most_volume_sendmessage_cb_t sendmsg_fptr) +{ + ApplyMostValue(this->_target_value, _type, _tx_payload); + + if (this->_is_available && !this->_is_busy) + { + sendmsg_fptr(this->_address, 0x100U, _tx_payload, _tx_payload_sz); + + this->_actual_value = this->_target_value; + } + + return true; +} + bool CDeviceValue::FireUpdateMessage(lib_most_volume_writei2c_cb_t writei2c_fptr, lib_most_volume_writei2c_result_cb_t result_fptr, void *result_user_ptr) |