minor cleanup master
authorJohn Tsiombikas <nuclear@member.fsf.org>
Tue, 9 Mar 2021 23:58:08 +0000 (01:58 +0200)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Tue, 9 Mar 2021 23:58:08 +0000 (01:58 +0200)
NOTES [new file with mode: 0644]
src/main.c
src/tda93xx.h [new file with mode: 0644]

diff --git a/NOTES b/NOTES
new file mode 100644 (file)
index 0000000..8e3ed1d
--- /dev/null
+++ b/NOTES
@@ -0,0 +1,30 @@
+TV model: LG RE21FB30RX
+Jungle IC: Philips TDA9361PS/N2/4I0793
+
+Remote control
+--------------
+RC-5 IR protocol, 36khz(?)
+ref: https://www.sbprojects.net/knowledge/ir/rc5.php
+
+  [s1|s2|T|<addr 5b>|<cmd 6b>]
+  \-------- 14 bits ---------/
+
+IR device address: 0
+
+commands:
+  0-9: program
+  0c: on/off
+  0d: mute
+  10: vol +
+  11: vol -
+  20: prog +
+  21: prog -
+  25: OK
+  
+  32: yellow
+  34: blue
+  36: green
+  37: red
+  
+  38: tv/av
+  3b: menu
index a3f30c8..49ffacc 100644 (file)
@@ -6,6 +6,7 @@
 #include <util/delay.h>
 #include "serial.h"
 #include "i2c.h"
+#include "tda93xx.h"
 
 enum {
        IR_CMD_ONOFF    = 0x0c,
@@ -42,11 +43,6 @@ enum {
        PEND_VOL        = 4
 };
 
-/* TODO
- * IR decoding, connected to PD2
- * enable/disable with switch on PCINT1
- * some of the buttons multiplexed on ADC0
- */
 #define PD_IR  2
 #define PD_ENSW        3
 
@@ -130,7 +126,9 @@ int main(void)
                pending = 0;
                sei();
                if((pend & PEND_IR) && !(ir_input & 0x8000)) {
-                       printf("IR addr: %02x  cmd: %02x  (%04x)\n", (ir_input >> 6) & 0x1f, ir_input & 0x3f, ir_input);
+                       if(dbgmode) {
+                               printf("IR addr: %02x  cmd: %02x  (%04x)\n", (ir_input >> 6) & 0x1f, ir_input & 0x3f, ir_input);
+                       }
 
                        if(((ir_input >> 6) & 0x1f) == 0) {     /* TV remote sends IR address 0 */
                                switch(ir_input & 0x3f) {
@@ -266,9 +264,11 @@ static void updhold(void)
 {
        data[0] = mute ? 0 : volume;
        data[1] = 0x1f;
-       i2c_write(0x8a, 0x1f, data, 1);
+       /*
+       i2c_write(JADDR, JSUB_VOLUME, data, 1);
        i2c_wait();
-       i2c_write(0x8a, 0x1c, data + 1, 1);
+       */
+       i2c_write(JADDR, JSUB_SATURATION, data + 1, 1);
        i2c_wait();
        i2c_hold();
 }
@@ -280,7 +280,7 @@ static unsigned char read_status(void)
        s = i2c_isheld() ? STAT_BUSHOLD : 0;
        if(enable) s |= STAT_EN;
 
-       i2c_read(0x8a, 0, data, 3);
+       i2c_read(JADDR, JSUB_STAT0, data, 3);
        if(s & STAT_BUSHOLD) {
                i2c_wait();
                i2c_hold();
@@ -323,7 +323,7 @@ static void proc_cmd(char *input)
 
                /* AV switch (22): 0 0 SVO CMB1 CMB0 INA INB 0 */
                data[0] = 0x22;
-               i2c_write(0x8a, 0x22, data, 1);
+               i2c_write(JADDR, JSUB_AVSWITCH, data, 1);
                i2c_async(i2c_hold);
 
        } else if(strcmp(input, "rgb") == 0) {
@@ -334,9 +334,9 @@ static void proc_cmd(char *input)
                 */
                data[0] = 0x70;
                data[1] = 0;
-               i2c_write(0x8a, 0x2a, data, 1);
+               i2c_write(JADDR, JSUB_CTRL0, data, 1);
                i2c_wait();
-               i2c_write(0x8a, 0x2b, data + 1, 1);
+               i2c_write(JADDR, JSUB_CTRL1, data + 1, 1);
 
        } else if(memcmp(input, "vol ", 4) == 0) {
                int vol = atoi(input + 4);
@@ -344,7 +344,7 @@ static void proc_cmd(char *input)
                        printf("ERR vol (%s)\n", input + 4);
                } else {
                        data[0] = vol;
-                       i2c_write(0x8a, 0x1f, data, 1);
+                       i2c_write(JADDR, JSUB_VOLUME, data, 1);
                        printf("OK volume: %d\n", vol);
                }
 
@@ -354,7 +354,7 @@ static void proc_cmd(char *input)
                if(data[0] <= 0 || data[0] > 0x3f) {
                        data[0] = 0x1f;
                }
-               i2c_write(0x8a, 0x1c, data, 1);
+               i2c_write(JADDR, JSUB_SATURATION, data, 1);
                i2c_async(i2c_hold);    /* hold I2C when done */
 
        } else if(strcmp(input, "rel") == 0) {
@@ -362,7 +362,7 @@ static void proc_cmd(char *input)
                i2c_release();
 
        } else if(strcmp(input, "status") == 0) {
-               i2c_read(0x8a, 0, data, 3);
+               i2c_read(JADDR, JSUB_STAT0, data, 3);
                i2c_async(printstat);
 
        } else if(memcmp(input, "rd ", 3) == 0) {
diff --git a/src/tda93xx.h b/src/tda93xx.h
new file mode 100644 (file)
index 0000000..fbb29e3
--- /dev/null
@@ -0,0 +1,53 @@
+#ifndef TDA93XX_H_
+#define TDA93XX_H_
+
+/* definitions for the TDA93xx jungle chip */
+#define JADDR  0x8a
+
+enum {
+       /* status (rd) */
+       JSUB_STAT0                      = 0x00, /* [POR|IFI|LOCK|SL|CD3|CD2|CD1|CD0] */
+       JSUB_STAT1                      = 0x01, /* [XPR|NDF|FSI|IVW|WBC|HBC|BCF|   ] */
+       JSUB_STAT2                      = 0x02, /* [SUP|   |IN2|QSS|AFA|AFB|FMW|FML] */
+
+       /* controls (wr) */
+       JSUB_HPARALLEL          = 0x06, /* 6bit (20h) */
+       JSUB_HBOW                       = 0x07, /* 6bit (20h) */
+       JSUB_HUE                        = 0x08, /* 6bit (0) */
+       JSUB_HSHIFT                     = 0x09, /* 6bit (20h) */
+       JSUB_EW_WIDTH           = 0x0a, /* 6bit (20h) */
+       JSUB_EW_PARABOLA        = 0x0b, /* 6bit (20h) */
+       JSUB_EW_UCORNER         = 0x0c, /* 6bit (20h) */
+       JSUB_EW_LCORNER         = 0x0d, /* 6bit (20h) */
+       JSUB_EW_TRAPEZ          = 0x0e, /* 6bit (20h) */
+       JSUB_VSLOPE                     = 0x0f, /* 6bit (20h) */
+       JSUB_VAMPL                      = 0x10, /* 6bit (20h) */
+       JSUB_SCORRECT           = 0x11, /* 6bit (20h) */
+       JSUB_VSHIFT                     = 0x12, /* 6bit (20h) */
+       JSUB_VZOOM                      = 0x13, /* 6bit (20h) */
+       JSUB_BLACK_OFFS_RG      = 0x15, /* [R|R|R|R|G|G|G|G] (88h) */
+       JSUB_WHITE_R            = 0x16, /* 6bit (20h) */
+       JSUB_WHITE_G            = 0x17, /* 6bit (20h) */
+       JSUB_WHITE_B            = 0x18, /* 6bit (20h) */
+       JSUB_PEAKING            = 0x19, /* 6bit (20h) */
+       JSUB_LUM_DELAY          = 0x1a, /* 4bit (0) */
+       JSUB_BRIGTHNESS         = 0x1b, /* 6bit (20h) */
+       JSUB_SATURATION         = 0x1c, /* 6bit (20h) */
+       JSUB_CONTRAST           = 0x1d, /* 6bit (20h) */
+       JSUB_AGC_TAKEOVER       = 0x1e, /* 6bit (20h) */
+       JSUB_VOLUME                     = 0x1f, /* 6bit (20h) */
+       JSUB_COLORDEC0          = 0x20, /* [CM3|CM2|CM1|CM0|MAT|MUS|ACL|CB ] (0) */
+       JSUB_COLORDEC1          = 0x21, /* [SIF| 0 | 0 | 0 | 0 | 0 |BPS|FCO] (0) */
+       JSUB_AVSWITCH           = 0x22, /* [0|0|SVO|CMB1|CMB0|INA|INB|0] (0) */
+       JSUB_SYNC0                      = 0x24, /* [ 0 |HP2|FOA|FOB|POC|STB|VIM|VID] (0) */
+       JSUB_SYNC1                      = 0x25, /* [ 0 | 0 |FSL|OSO|FORF|FORS|DL|NCIN] (0) */
+       JSUB_DEFLECTION         = 0x26, /* [ 0 | 0 | 0 | 0 |SBL|VSD|EVG|HCO] (0) */
+       JSUB_VIS_IF0            = 0x27, /* [IFA|IFB|IFC|VSW|MOD|AFW|IFS|STM] (0) */
+       JSUB_VIS_IF1            = 0x28, /* [ 0 | 0 | 0 | 0 | 0 |AGC1|AGC0|FFI] (0) */
+       JSUB_SOUND                      = 0x29, /* [BTSC|SM1|FMWS|AM|SM0|AVL|FMA|FMB] (0) */
+       JSUB_CTRL0                      = 0x2a, /* [ 0 |IE1|RBL|AKB|CL3|CL2|CL1|CL0] (0) */
+       JSUB_CTRL1                      = 0x2b, /* [ 0 | 0 | 0 | 0 | 0 | 0 |YUV|HBL] (0) */
+       JSUB_FEATURES0          = 0x2d  /* [ ......................... |BKS] (0) */
+};
+
+#endif /* TDA93XX_H_ */