summaryrefslogtreecommitdiffstats
path: root/MOST_UNICENS/ucs2-vol
diff options
context:
space:
mode:
authorTobias Jahnke <tobias.jahnke@microchip.com>2018-10-10 15:52:57 +0200
committerTobias Jahnke <tobias.jahnke@microchip.com>2018-10-12 12:32:24 +0000
commit178a830b8ad85813b7bf0b271be79f3a8d3a6277 (patch)
tree8d31174db1ff79796c91588c2fc47fe1fbdad648 /MOST_UNICENS/ucs2-vol
parentf938776e3cdeba1375a866e12f66a5b9c4151627 (diff)
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')
-rw-r--r--MOST_UNICENS/ucs2-vol/inc/device_value.h7
-rw-r--r--MOST_UNICENS/ucs2-vol/inc/libmostvolume.h3
-rw-r--r--MOST_UNICENS/ucs2-vol/inc/setup.h2
-rw-r--r--MOST_UNICENS/ucs2-vol/src/device_container.cpp23
-rw-r--r--MOST_UNICENS/ucs2-vol/src/device_value.cpp33
-rw-r--r--MOST_UNICENS/ucs2-vol/src/libmostvolume.cpp2
-rw-r--r--MOST_UNICENS/ucs2-vol/src/setup.cpp26
7 files changed, 71 insertions, 25 deletions
diff --git a/MOST_UNICENS/ucs2-vol/inc/device_value.h b/MOST_UNICENS/ucs2-vol/inc/device_value.h
index bc8f142..c2fe0b1 100644
--- a/MOST_UNICENS/ucs2-vol/inc/device_value.h
+++ b/MOST_UNICENS/ucs2-vol/inc/device_value.h
@@ -53,13 +53,14 @@ struct STxMessage {
enum DeviceValueType {
DEVICE_VAL_MASTER = 0,
DEVICE_VAL_LEFT = 1,
- DEVICE_VAL_RIGHT = 2
+ DEVICE_VAL_RIGHT = 2,
+ DEVICE_VAL_FIBERDYNE_MASTER = 3
};
class CDeviceValue {
public:
- CDeviceValue(uint16_t address, DeviceValueType type, uint16_t key);
+ CDeviceValue(uint16_t address, DeviceValueType type, uint16_t key, bool is_i2c);
virtual ~CDeviceValue();
uint16_t GetKey(){return _key;}
@@ -72,6 +73,7 @@ public:
bool FireUpdateMessage(lib_most_volume_writei2c_cb_t writei2c_fptr,
lib_most_volume_writei2c_result_cb_t result_fptr,
void *result_user_ptr);// fires message & updates actual value
+ bool FireControlMessage(lib_most_volume_sendmessage_cb_t sendmsg_fptr);
void SetAvailable(bool active){this->_is_available = active; _actual_value = 0x01u;}
bool IsAvailable() {return this->_is_available;}
@@ -84,6 +86,7 @@ private:
bool _is_available; // related node is available
bool _is_busy; // do not update while busy
+ bool _is_i2c;
DeviceValueType _type; // determines the remote i2c command
uint16_t _key; // lookup key
uint16_t _address; // target node/group address
diff --git a/MOST_UNICENS/ucs2-vol/inc/libmostvolume.h b/MOST_UNICENS/ucs2-vol/inc/libmostvolume.h
index 1147993..5335754 100644
--- a/MOST_UNICENS/ucs2-vol/inc/libmostvolume.h
+++ b/MOST_UNICENS/ucs2-vol/inc/libmostvolume.h
@@ -63,9 +63,12 @@ typedef int (*lib_most_volume_writei2c_cb_t)(uint16_t node, uint8_t *data_ptr, u
lib_most_volume_writei2c_result_cb_t result_fptr,
void *result_user_ptr);
+typedef int (*lib_most_volume_sendmessage_cb_t)(uint16_t node, uint16_t msgid, uint8_t *data_ptr, uint8_t data_sz);
+
typedef struct lib_most_volume_init_ {
lib_most_volume_service_cb_t service_cb;
lib_most_volume_writei2c_cb_t writei2c_cb;
+ lib_most_volume_sendmessage_cb_t sendmsg_cb;
} lib_most_volume_init_t;
diff --git a/MOST_UNICENS/ucs2-vol/inc/setup.h b/MOST_UNICENS/ucs2-vol/inc/setup.h
index e7cda01..3be8bf4 100644
--- a/MOST_UNICENS/ucs2-vol/inc/setup.h
+++ b/MOST_UNICENS/ucs2-vol/inc/setup.h
@@ -51,6 +51,8 @@ private:
CDeviceValue _volume_amp_272_m;
CDeviceValue _volume_amp_272_l;
CDeviceValue _volume_amp_272_r;
+
+ CDeviceValue _volume_amp_510_m;
CDeviceContainer _value_container;
lib_most_volume_init_t init_data;
diff --git a/MOST_UNICENS/ucs2-vol/src/device_container.cpp b/MOST_UNICENS/ucs2-vol/src/device_container.cpp
index f8b1961..3448a23 100644
--- a/MOST_UNICENS/ucs2-vol/src/device_container.cpp
+++ b/MOST_UNICENS/ucs2-vol/src/device_container.cpp
@@ -119,18 +119,25 @@ void CDeviceContainer::Update()
if (_values_pptr[_idx_processing]->RequiresUpdate())
{
- if (_values_pptr[_idx_processing]->FireUpdateMessage(this->_init_ptr->writei2c_cb,
- &OnI2cResult,
- this))
+ if (_values_pptr[_idx_processing]->GetType() == DEVICE_VAL_FIBERDYNE_MASTER)
{
- this->_tx_busy = true;
- error = false;
- break;
+ _values_pptr[_idx_processing]->FireControlMessage(this->_init_ptr->sendmsg_cb);
}
else
{
- error = true;
- break;
+ if (_values_pptr[_idx_processing]->FireUpdateMessage(this->_init_ptr->writei2c_cb,
+ &OnI2cResult,
+ this))
+ {
+ this->_tx_busy = true;
+ error = false;
+ break;
+ }
+ else
+ {
+ error = true;
+ break;
+ }
}
}
}
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)
diff --git a/MOST_UNICENS/ucs2-vol/src/libmostvolume.cpp b/MOST_UNICENS/ucs2-vol/src/libmostvolume.cpp
index 5eea3fd..35f769f 100644
--- a/MOST_UNICENS/ucs2-vol/src/libmostvolume.cpp
+++ b/MOST_UNICENS/ucs2-vol/src/libmostvolume.cpp
@@ -23,6 +23,7 @@
#include "libmostvolume.h"
#include "setup.h"
+#include <afb/afb-binding.h>
/*#include <iostream>*/
static bool _running = false;
@@ -61,6 +62,7 @@ extern "C" uint8_t lib_most_volume_set(enum lib_most_volume_channel_t channel, u
{
uint8_t success = 1U;
/*std::cerr << "lib_most_volume_set(): channel=" << channel << ", volume=" << (int)volume << std::endl;*/
+ AFB_NOTICE("lib_most_volume_set");
if (_running)
{
diff --git a/MOST_UNICENS/ucs2-vol/src/setup.cpp b/MOST_UNICENS/ucs2-vol/src/setup.cpp
index dd6675b..ad841ab 100644
--- a/MOST_UNICENS/ucs2-vol/src/setup.cpp
+++ b/MOST_UNICENS/ucs2-vol/src/setup.cpp
@@ -43,18 +43,19 @@ void CSetup::Release() {
}
CSetup::CSetup()
- : _volume_amp_270_m(0x270U, DEVICE_VAL_MASTER, LIB_MOST_VOLUME_MASTER),
- _volume_amp_270_l(0x270U, DEVICE_VAL_LEFT, LIB_MOST_VOLUME_CH_FRONT_LEFT),
- _volume_amp_270_r(0x270U, DEVICE_VAL_RIGHT, LIB_MOST_VOLUME_CH_FRONT_RIGHT),
- _volume_amp_271_m(0x271U, DEVICE_VAL_MASTER, LIB_MOST_VOLUME_MASTER),
- _volume_amp_271_l(0x271U, DEVICE_VAL_LEFT, LIB_MOST_VOLUME_CH_REAR_LEFT),
- _volume_amp_271_r(0x271U, DEVICE_VAL_RIGHT, LIB_MOST_VOLUME_CH_REAR_RIGHT),
- _volume_amp_272_m(0x272U, DEVICE_VAL_MASTER, LIB_MOST_VOLUME_MASTER),
- _volume_amp_272_l(0x272U, DEVICE_VAL_LEFT, LIB_MOST_VOLUME_CH_CENTER),
- _volume_amp_272_r(0x272U, DEVICE_VAL_RIGHT, LIB_MOST_VOLUME_CH_SUB),
+ : _volume_amp_270_m(0x270U, DEVICE_VAL_MASTER, LIB_MOST_VOLUME_MASTER, true),
+ _volume_amp_270_l(0x270U, DEVICE_VAL_LEFT, LIB_MOST_VOLUME_CH_FRONT_LEFT, true),
+ _volume_amp_270_r(0x270U, DEVICE_VAL_RIGHT, LIB_MOST_VOLUME_CH_FRONT_RIGHT, true),
+ _volume_amp_271_m(0x271U, DEVICE_VAL_MASTER, LIB_MOST_VOLUME_MASTER, true),
+ _volume_amp_271_l(0x271U, DEVICE_VAL_LEFT, LIB_MOST_VOLUME_CH_REAR_LEFT, true),
+ _volume_amp_271_r(0x271U, DEVICE_VAL_RIGHT, LIB_MOST_VOLUME_CH_REAR_RIGHT, true),
+ _volume_amp_272_m(0x272U, DEVICE_VAL_MASTER, LIB_MOST_VOLUME_MASTER, true),
+ _volume_amp_272_l(0x272U, DEVICE_VAL_LEFT, LIB_MOST_VOLUME_CH_CENTER, true),
+ _volume_amp_272_r(0x272U, DEVICE_VAL_RIGHT, LIB_MOST_VOLUME_CH_SUB, true),
+ _volume_amp_510_m(0x510U, DEVICE_VAL_FIBERDYNE_MASTER, LIB_MOST_VOLUME_MASTER, false),
_value_container()
{
- static CDeviceValue* value_list[9] = { &_volume_amp_270_m,
+ static CDeviceValue* value_list[10] = { &_volume_amp_270_m,
&_volume_amp_270_l,
&_volume_amp_270_r,
&_volume_amp_271_m,
@@ -62,9 +63,10 @@ CSetup::CSetup()
&_volume_amp_271_r,
&_volume_amp_272_m,
&_volume_amp_272_l,
- &_volume_amp_272_r};
+ &_volume_amp_272_r,
+ &_volume_amp_510_m};
- _value_container.RegisterValues(value_list, 9U);
+ _value_container.RegisterValues(value_list, 10U);
}
CSetup::~CSetup()