#include <util/delay.h>
#include "serial.h"
#include "i2c.h"
+#include "tda93xx.h"
enum {
IR_CMD_ONOFF = 0x0c,
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
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) {
{
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();
}
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();
/* 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) {
*/
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);
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);
}
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) {
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) {
--- /dev/null
+#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_ */