[Feature][T8TSK-289]fix codec compile fail for gsw and zk
Only Configure: No
Affected branch: LYNQ_PUBLIC
Affected module: codec
Is it affected on both ZXIC and MTK: only MTK
Self-test: No
Doc Update: No
Change-Id: I21962585c7e6e94b641335d10ee50811ae0e10dd
diff --git a/IC_src/mtk/lib/liblynq-codec/liblynq-codec/lynq_codec.c b/IC_src/mtk/lib/liblynq-codec/liblynq-codec/lynq_codec.c
index 9cd770d..f42ba33 100755
--- a/IC_src/mtk/lib/liblynq-codec/liblynq-codec/lynq_codec.c
+++ b/IC_src/mtk/lib/liblynq-codec/liblynq-codec/lynq_codec.c
@@ -1,5 +1,9 @@
#include <stdio.h>
#include <stdlib.h>
+#include <fcntl.h>
+#include <linux/i2c-dev.h>
+#include <sys/ioctl.h>
+#include <unistd.h>
#include "lynq_codec.h"
#include <syslog.h>
#include <log/log.h>
@@ -293,7 +297,7 @@
void set_codec(media_src_t src, codec_op open_close)
{
- RLOGD("set_zk_3104_codec src=[%d] op=[%d]", src, open);
+ RLOGD("set_zk_3104_codec src=[%d] op=[%d]", src, open_close);
set_zk_3104_codec(open_close);
}
@@ -368,14 +372,14 @@
int customer_get_pa_volume(int* volume)
{
- int file;
+int file;
char *filename = "/dev/i2c-0";
int addr = 0x6c;
char buf[2];
- if (volume < 1 || volume > 4)
+ if(volume == NULL)
{
- RLOGE("Invalid volume specified\n");
+ RLOGE("lynq_get_pa_volume Invalid pointer to volume\n");
return -1;
}
@@ -392,44 +396,35 @@
return -1;
}
- switch (volume) {
- case 1:
- buf[0] = 0x03;
- buf[1] = 0x00; //Gain set to 20 dB
- break;
- case 2:
- buf[0] = 0x03;
- buf[1] = 0x78; //Gain set to 26 dB
- break;
- case 3:
- buf[0] = 0x03;
- buf[1] = 0x80; //Gain set to 32 dB
- break;
- case 4:
- buf[0] = 0x03;
- buf[1] = 0xc0; //Gain set to 36 dB
- break;
- }
+ buf[0] = 0x03;
- if (write(file, buf, 2) != 2)
+ if (write(file, buf, 1) != 1)
{
RLOGE("Failed to write to the i2c bus\n");
close(file);
return -1;
}
- RLOGE("Set the 0x%02x register value to 0x%02x\n", buf[0], buf[1]);
+ if (read(file, buf, 1) != 1)
+ {
+ RLOGE("Failed to read from the i2c bus\n");
+ close(file);
+ return -1;
+ }
close(file);
+ *volume = (buf[0] >> 6) + 1;
+
return 0;
+
}
#elif defined(GSW_CODEC_CFG)
void set_codec(media_src_t src, codec_op open_close)
{
- RLOGD("set_gsw_3104_codec src=[%d] op=[%d]", src, open);
+ RLOGD("set_gsw_3104_codec src=[%d] op=[%d]", src, open_close);
set_gsw_3104_codec(open_close);
}