diff options
author | Johannes Stezenbach <devnull@localhost> | 2004-01-05 19:51:19 +0000 |
---|---|---|
committer | Johannes Stezenbach <devnull@localhost> | 2004-01-05 19:51:19 +0000 |
commit | 40bde0c39cea6b6c6f43b4e63ae30ea5e6608d63 (patch) | |
tree | 47fa4ff8bd684811e3fd47d83a68dbdc949f0c4f /linux | |
parent | 48322faf20f97a8bbb774bd63689228a8ff20c26 (diff) | |
download | mediapointer-dvb-s2-40bde0c39cea6b6c6f43b4e63ae30ea5e6608d63.tar.gz mediapointer-dvb-s2-40bde0c39cea6b6c6f43b4e63ae30ea5e6608d63.tar.bz2 |
- use time_after() for timeouts
- added some comments about firmware interface
- coding style and whitespace cleanups
Diffstat (limited to 'linux')
-rw-r--r-- | linux/drivers/media/dvb/ttpci/av7110_hw.c | 1304 | ||||
-rw-r--r-- | linux/drivers/media/dvb/ttpci/av7110_hw.h | 340 |
2 files changed, 833 insertions, 811 deletions
diff --git a/linux/drivers/media/dvb/ttpci/av7110_hw.c b/linux/drivers/media/dvb/ttpci/av7110_hw.c index 813ed90fd..80386683e 100644 --- a/linux/drivers/media/dvb/ttpci/av7110_hw.c +++ b/linux/drivers/media/dvb/ttpci/av7110_hw.c @@ -55,8 +55,7 @@ extern int av7110_debug; int av7110_debiwrite(struct av7110 *av7110, u32 config, int addr, u32 val, int count) { - struct saa7146_dev *dev = av7110->dev; - u32 cmd; + struct saa7146_dev *dev = av7110->dev; if (count <= 0 || count > 32764) return -1; @@ -67,14 +66,14 @@ int av7110_debiwrite(struct av7110 *av7110, u32 config, saa7146_write(dev, DEBI_AD, val); else /* block transfer */ saa7146_write(dev, DEBI_AD, av7110->debi_bus); - saa7146_write(dev, DEBI_COMMAND, (cmd = (count << 17) | (addr & 0xffff))); + saa7146_write(dev, DEBI_COMMAND, (count << 17) | (addr & 0xffff)); saa7146_write(dev, MC2, (2 << 16) | 2); return 0; } u32 av7110_debiread(struct av7110 *av7110, u32 config, int addr, int count) { - struct saa7146_dev *dev = av7110->dev; + struct saa7146_dev *dev = av7110->dev; u32 result = 0; if (count > 32764 || count <= 0) @@ -90,34 +89,195 @@ u32 av7110_debiread(struct av7110 *av7110, u32 config, int addr, int count) return count; saa7146_wait_for_debi_done(av7110->dev); result = saa7146_read(dev, DEBI_AD); - result &= (0xffffffffUL >> ((4-count)*8)); + result &= (0xffffffffUL >> ((4 - count) * 8)); return result; } + + +/* av7110 ARM core boot stuff */ + void reset_arm(struct av7110 *av7110) { - saa7146_setgpio(av7110->dev, RESET_LINE, SAA7146_GPIO_OUTLO); + saa7146_setgpio(av7110->dev, RESET_LINE, SAA7146_GPIO_OUTLO); - /* Disable DEBI and GPIO irq */ + /* Disable DEBI and GPIO irq */ IER_DISABLE(av7110->dev, (MASK_19 | MASK_03)); -// saa7146_write(av7110->dev, IER, -// saa7146_read(av7110->dev, IER) & ~(MASK_19 | MASK_03)); - saa7146_write(av7110->dev, ISR, (MASK_19 | MASK_03)); + saa7146_write(av7110->dev, ISR, (MASK_19 | MASK_03)); - mdelay(800); - saa7146_setgpio(av7110->dev, RESET_LINE, SAA7146_GPIO_OUTHI); - mdelay(800); + //FIXME: are those mdelays really necessary? + mdelay(800); + saa7146_setgpio(av7110->dev, RESET_LINE, SAA7146_GPIO_OUTHI); + mdelay(800); - ARM_ResetMailBox(av7110); + ARM_ResetMailBox(av7110); + + saa7146_write(av7110->dev, ISR, (MASK_19 | MASK_03)); + IER_ENABLE(av7110->dev, MASK_03); - saa7146_write(av7110->dev, ISR, (MASK_19 | MASK_03)); + av7110->arm_ready = 1; + printk("av7110: ARM RESET\n"); +} + + +static int waitdebi(struct av7110 *av7110, int adr, int state) +{ + int k; + + DEB_EE(("av7110: %p\n", av7110)); + + for (k = 0; k < 100; k++) { + if (irdebi(av7110, DEBINOSWAP, adr, 0, 2) == state) + return 0; + udelay(500); + } + return -1; +} + +static int load_dram(struct av7110 *av7110, u32 *data, int len) +{ + int i; + int blocks, rest; + u32 base, bootblock = BOOT_BLOCK; + + DEB_EE(("av7110: %p\n", av7110)); + + blocks = len / BOOT_MAX_SIZE; + rest = len % BOOT_MAX_SIZE; + base = DRAM_START_CODE; + + for (i = 0; i < blocks; i++) { + if (waitdebi(av7110, BOOT_STATE, BOOTSTATE_BUFFER_EMPTY) < 0) + return -1; + DEB_D(("Writing DRAM block %d\n", i)); + mwdebi(av7110, DEBISWAB, bootblock, + ((char*)data) + i * BOOT_MAX_SIZE, BOOT_MAX_SIZE); + bootblock ^= 0x1400; + iwdebi(av7110, DEBISWAB, BOOT_BASE, swab32(base), 4); + iwdebi(av7110, DEBINOSWAP, BOOT_SIZE, BOOT_MAX_SIZE, 2); + iwdebi(av7110, DEBINOSWAP, BOOT_STATE, BOOTSTATE_BUFFER_FULL, 2); + base += BOOT_MAX_SIZE; + } + + if (rest > 0) { + if (waitdebi(av7110, BOOT_STATE, BOOTSTATE_BUFFER_EMPTY) < 0) + return -1; + if (rest > 4) + mwdebi(av7110, DEBISWAB, bootblock, + ((char*)data) + i * BOOT_MAX_SIZE, rest); + else + mwdebi(av7110, DEBISWAB, bootblock, + ((char*)data) + i * BOOT_MAX_SIZE - 4, rest + 4); + + iwdebi(av7110, DEBISWAB, BOOT_BASE, swab32(base), 4); + iwdebi(av7110, DEBINOSWAP, BOOT_SIZE, rest, 2); + iwdebi(av7110, DEBINOSWAP, BOOT_STATE, BOOTSTATE_BUFFER_FULL, 2); + } + if (waitdebi(av7110, BOOT_STATE, BOOTSTATE_BUFFER_EMPTY) < 0) + return -1; + iwdebi(av7110, DEBINOSWAP, BOOT_SIZE, 0, 2); + iwdebi(av7110, DEBINOSWAP, BOOT_STATE, BOOTSTATE_BUFFER_FULL, 2); + if (waitdebi(av7110, BOOT_STATE, BOOTSTATE_BOOT_COMPLETE) < 0) + return -1; + return 0; +} + +/* we cannot write av7110 DRAM directly, so load a bootloader into + * the DPRAM which implements a simple boot protocol */ +static u8 bootcode[] = { + 0xea, 0x00, 0x00, 0x0e, 0xe1, 0xb0, 0xf0, 0x0e, /* 0x0000 */ + 0xe2, 0x5e, 0xf0, 0x04, 0xe2, 0x5e, 0xf0, 0x04, + 0xe2, 0x5e, 0xf0, 0x08, 0xe2, 0x5e, 0xf0, 0x04, + 0xe2, 0x5e, 0xf0, 0x04, 0xe2, 0x5e, 0xf0, 0x04, + 0x2c, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x0c, + 0x00, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x34, + 0x00, 0x00, 0x00, 0x00, 0xa5, 0xa5, 0x5a, 0x5a, + 0x00, 0x1f, 0x15, 0x55, 0x00, 0x00, 0x00, 0x09, + 0xe5, 0x9f, 0xd0, 0x5c, 0xe5, 0x9f, 0x40, 0x54, /* 0x0040 */ + 0xe3, 0xa0, 0x00, 0x00, 0xe5, 0x84, 0x00, 0x00, + 0xe5, 0x84, 0x00, 0x04, 0xe1, 0xd4, 0x10, 0xb0, + 0xe3, 0x51, 0x00, 0x00, 0x0a, 0xff, 0xff, 0xfc, + 0xe1, 0xa0, 0x10, 0x0d, 0xe5, 0x94, 0x30, 0x04, + 0xe1, 0xd4, 0x20, 0xb2, 0xe2, 0x82, 0x20, 0x3f, + 0xe1, 0xb0, 0x23, 0x22, 0x03, 0xa0, 0x00, 0x02, + 0xe1, 0xc4, 0x00, 0xb0, 0x0a, 0xff, 0xff, 0xf4, + 0xe8, 0xb1, 0x1f, 0xe0, 0xe8, 0xa3, 0x1f, 0xe0, /* 0x0080 */ + 0xe8, 0xb1, 0x1f, 0xe0, 0xe8, 0xa3, 0x1f, 0xe0, + 0xe2, 0x52, 0x20, 0x01, 0x1a, 0xff, 0xff, 0xf9, + 0xe2, 0x2d, 0xdb, 0x05, 0xea, 0xff, 0xff, 0xec, + 0x2c, 0x00, 0x03, 0xf8, 0x2c, 0x00, 0x04, 0x00, +}; + +int bootarm(struct av7110 *av7110) +{ + struct saa7146_dev *dev = av7110->dev; + u32 ret; + int i; + + DEB_EE(("av7110: %p\n", av7110)); + + saa7146_setgpio(dev, RESET_LINE, SAA7146_GPIO_OUTLO); + + /* Disable DEBI and GPIO irq */ + IER_DISABLE(av7110->dev, MASK_03 | MASK_19); + saa7146_write(av7110->dev, ISR, (MASK_19 | MASK_03)); + + /* enable DEBI */ + saa7146_write(av7110->dev, MC1, 0x08800880); + saa7146_write(av7110->dev, DD1_STREAM_B, 0x00000000); + saa7146_write(av7110->dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26)); + + /* test DEBI */ + iwdebi(av7110, DEBISWAP, DPRAM_BASE, 0x76543210, 4); + if ((ret=irdebi(av7110, DEBINOSWAP, DPRAM_BASE, 0, 4)) != 0x10325476) { + printk(KERN_ERR "dvb: debi test in bootarm() failed: " + "%08x != %08x (check your BIOS notplug settings)\n", + ret, 0x10325476); + return -1; + } + for (i = 0; i < 8192; i += 4) + iwdebi(av7110, DEBISWAP, DPRAM_BASE + i, 0x00, 4); + DEB_D(("bootarm: debi test OK\n")); + + /* boot */ + DEB_D(("bootarm: load boot code\n")); + saa7146_setgpio(dev, ARM_IRQ_LINE, SAA7146_GPIO_IRQLO); + //saa7146_setgpio(dev, DEBI_DONE_LINE, SAA7146_GPIO_INPUT); + //saa7146_setgpio(dev, 3, SAA7146_GPIO_INPUT); + + mwdebi(av7110, DEBISWAB, DPRAM_BASE, bootcode, sizeof(bootcode)); + iwdebi(av7110, DEBINOSWAP, BOOT_STATE, BOOTSTATE_BUFFER_FULL, 2); + + saa7146_wait_for_debi_done(av7110->dev); + saa7146_setgpio(dev, RESET_LINE, SAA7146_GPIO_OUTHI); + //FIXME: necessary? + set_current_state(TASK_INTERRUPTIBLE); + schedule_timeout(HZ); + + DEB_D(("bootarm: load dram code\n")); + if (load_dram(av7110, (u32 *)av7110->bin_root, av7110->size_root) < 0) + return -1; + + saa7146_setgpio(dev, RESET_LINE, SAA7146_GPIO_OUTLO); + mdelay(1); + + DEB_D(("bootarm: load dpram code\n")); + mwdebi(av7110, DEBISWAB, DPRAM_BASE, av7110->bin_dpram, av7110->size_dpram); + + saa7146_wait_for_debi_done(av7110->dev); + saa7146_setgpio(dev, RESET_LINE, SAA7146_GPIO_OUTHI); + //FIXME: necessary? + mdelay(800); + + //ARM_ClearIrq(av7110); + ARM_ResetMailBox(av7110); + saa7146_write(av7110->dev, ISR, (MASK_19 | MASK_03)); IER_ENABLE(av7110->dev, MASK_03); -// saa7146_write(av7110->dev, IER, -// saa7146_read(av7110->dev, IER) | MASK_03 ); - av7110->arm_ready = 1; - printk("av7110: ARM RESET\n"); + av7110->arm_errors = 0; + av7110->arm_ready = 1; + return 0; } @@ -127,67 +287,67 @@ void reset_arm(struct av7110 *av7110) int OutCommand(struct av7110 *av7110, u16* buf, int length) { - int i; - u32 start; + int i; + u32 start; #ifdef COM_DEBUG - u32 stat; + u32 stat; #endif -// DEB_EE(("av7110: %p\n",av7110)); +// DEB_EE(("av7110: %p\n", av7110)); if (!av7110->arm_ready) { DEB_D(("arm not ready.\n")); return -1; } - start = jiffies; - while (rdebi(av7110, DEBINOSWAP, COMMAND, 0, 2 )) { - dvb_delay(1); - if ((jiffies - start) > ARM_WAIT_FREE) { + start = jiffies; + while (rdebi(av7110, DEBINOSWAP, COMMAND, 0, 2 )) { + dvb_delay(1); + if (time_after(jiffies, start + ARM_WAIT_FREE)) { printk(KERN_ERR "%s: timeout waiting for COMMAND idle\n", __FUNCTION__); - return -1; - } - } + return -1; + } + } #ifndef _NOHANDSHAKE - start = jiffies; - while (rdebi(av7110, DEBINOSWAP, HANDSHAKE_REG, 0, 2 )) { - dvb_delay(1); - if ((jiffies - start) > ARM_WAIT_SHAKE) { + start = jiffies; + while (rdebi(av7110, DEBINOSWAP, HANDSHAKE_REG, 0, 2 )) { + dvb_delay(1); + if (time_after(jiffies, start + ARM_WAIT_SHAKE)) { printk(KERN_ERR "%s: timeout waiting for HANDSHAKE_REG\n", __FUNCTION__); - return -1; - } - } + return -1; + } + } #endif - start = jiffies; - while (rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2) & OSDQFull) { - dvb_delay(1); - if ((jiffies - start) > ARM_WAIT_OSD) { + start = jiffies; + while (rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2) & OSDQFull) { + dvb_delay(1); + if (time_after(jiffies, start + ARM_WAIT_OSD)) { printk(KERN_ERR "%s: timeout waiting for !OSDQFull\n", __FUNCTION__); return -1; - } - } - for (i = 2; i < length; i++) - wdebi(av7110, DEBINOSWAP, COMMAND + 2*i, (u32) buf[i], 2); + } + } + for (i = 2; i < length; i++) + wdebi(av7110, DEBINOSWAP, COMMAND + 2 * i, (u32) buf[i], 2); - if (length) - wdebi(av7110, DEBINOSWAP, COMMAND + 2, (u32) buf[1], 2); - else - wdebi(av7110, DEBINOSWAP, COMMAND + 2, 0, 2); + if (length) + wdebi(av7110, DEBINOSWAP, COMMAND + 2, (u32) buf[1], 2); + else + wdebi(av7110, DEBINOSWAP, COMMAND + 2, 0, 2); - wdebi(av7110, DEBINOSWAP, COMMAND, (u32) buf[0], 2); + wdebi(av7110, DEBINOSWAP, COMMAND, (u32) buf[0], 2); #ifdef COM_DEBUG - start = jiffies; - while (rdebi(av7110, DEBINOSWAP, COMMAND, 0, 2 )) { - dvb_delay(1); - if ((jiffies - start) > ARM_WAIT_FREE) { - printk(KERN_ERR "%s: timeout waiting for COMMAND to complete\n", + start = jiffies; + while (rdebi(av7110, DEBINOSWAP, COMMAND, 0, 2 )) { + dvb_delay(1); + if (time_after(jiffies, start + ARM_WAIT_FREE)) { + printk(KERN_ERR "%s: timeout waiting for COMMAND to complete\n", __FUNCTION__); - return -1; - } - } + return -1; + } + } stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2); if (stat & GPMQOver) { @@ -200,60 +360,60 @@ int OutCommand(struct av7110 *av7110, u16* buf, int length) } #endif - return 0; + return 0; } int SOutCommand(struct av7110 *av7110, u16* buf, int length) { - int ret; + int ret; -// DEB_EE(("av7110: %p\n",av7110)); +// DEB_EE(("av7110: %p\n", av7110)); - if (!av7110->arm_ready) { + if (!av7110->arm_ready) { DEB_D(("arm not ready.\n")); return -1; } - if (down_interruptible(&av7110->dcomlock)) + if (down_interruptible(&av7110->dcomlock)) return -ERESTARTSYS; - ret = OutCommand(av7110, buf, length); - up(&av7110->dcomlock); + ret = OutCommand(av7110, buf, length); + up(&av7110->dcomlock); if (ret) - printk("SOutCommand error\n"); - return ret; + printk("SOutCommand error\n"); + return ret; } int outcom(struct av7110 *av7110, int type, int com, int num, ...) { va_list args; - u16 buf[num + 2]; - int i, ret; + u16 buf[num + 2]; + int i, ret; // DEB_EE(("av7110: %p\n",av7110)); - buf[0] = ((type << 8) | com); - buf[1] = num; + buf[0] = ((type << 8) | com); + buf[1] = num; - if (num) { - va_start(args, num); - for (i = 0; i < num; i++) - buf[i + 2] = va_arg(args, u32); - va_end(args); - } + if (num) { + va_start(args, num); + for (i = 0; i < num; i++) + buf[i + 2] = va_arg(args, u32); + va_end(args); + } - ret = SOutCommand(av7110, buf, num + 2); + ret = SOutCommand(av7110, buf, num + 2); if (ret) - printk("outcom error\n"); + printk("outcom error\n"); return ret; } int SendCICommand(struct av7110 *av7110, u8 subcom, u8 *Params, u8 ParamLen) { - int i, ret; - u16 CommandBuffer[18] = { ((COMTYPE_COMMON_IF << 8) + subcom), - 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + int i, ret; + u16 CommandBuffer[18] = { ((COMTYPE_COMMON_IF << 8) + subcom), + 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - DEB_EE(("av7110: %p\n",av7110)); + DEB_EE(("av7110: %p\n", av7110)); for(i = 0; i < ParamLen && i < 32; i++) { @@ -263,86 +423,86 @@ int SendCICommand(struct av7110 *av7110, u8 subcom, u8 *Params, u8 ParamLen) CommandBuffer[(i / 2) + 2] |= Params[i]; } - ret = SOutCommand(av7110, CommandBuffer, 18); + ret = SOutCommand(av7110, CommandBuffer, 18); if (ret) - printk("SendCICommand error\n"); + printk("SendCICommand error\n"); return ret; } int CommandRequest(struct av7110 *av7110, u16 *Buff, int length, u16 *buf, int n) { int err; - s16 i; - u32 start; + s16 i; + u32 start; #ifdef COM_DEBUG - u32 stat; + u32 stat; #endif DEB_EE(("av7110: %p\n", av7110)); - if (!av7110->arm_ready) { + if (!av7110->arm_ready) { DEB_D(("arm not ready.\n")); return -1; } - if (down_interruptible(&av7110->dcomlock)) + if (down_interruptible(&av7110->dcomlock)) return -ERESTARTSYS; - if ((err = OutCommand(av7110, Buff, length)) < 0) { + if ((err = OutCommand(av7110, Buff, length)) < 0) { up(&av7110->dcomlock); printk("CommandRequest error\n"); return err; } - start = jiffies; - while (rdebi(av7110, DEBINOSWAP, COMMAND, 0, 2)) { + start = jiffies; + while (rdebi(av7110, DEBINOSWAP, COMMAND, 0, 2)) { #ifdef _NOHANDSHAKE - dvb_delay(1); + dvb_delay(1); #endif - if ((jiffies - start) > ARM_WAIT_FREE) { + if (time_after(jiffies, start + ARM_WAIT_FREE)) { printk("%s: timeout waiting for COMMAND to complete\n", __FUNCTION__); - up(&av7110->dcomlock); - return -1; - } - } + up(&av7110->dcomlock); + return -1; + } + } #ifndef _NOHANDSHAKE - start = jiffies; - while (rdebi(av7110, DEBINOSWAP, HANDSHAKE_REG, 0, 2 )) { - dvb_delay(1); - if ((jiffies - start) > ARM_WAIT_SHAKE) { + start = jiffies; + while (rdebi(av7110, DEBINOSWAP, HANDSHAKE_REG, 0, 2 )) { + dvb_delay(1); + if (time_after(jiffies, start + ARM_WAIT_SHAKE)) { printk(KERN_ERR "%s: timeout waiting for HANDSHAKE_REG\n", __FUNCTION__); - up(&av7110->dcomlock); - return -1; - } - } + up(&av7110->dcomlock); + return -1; + } + } #endif #ifdef COM_DEBUG stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2); if (stat & GPMQOver) { printk(KERN_ERR "%s: GPMQOver\n", __FUNCTION__); - up(&av7110->dcomlock); + up(&av7110->dcomlock); return -1; } else if (stat & OSDQOver) { printk(KERN_ERR "%s: OSDQOver\n", __FUNCTION__); - up(&av7110->dcomlock); + up(&av7110->dcomlock); return -1; } #endif - for (i = 0; i < n; i++) - buf[i] = rdebi(av7110, DEBINOSWAP, COM_BUFF + 2 * i, 0, 2); + for (i = 0; i < n; i++) + buf[i] = rdebi(av7110, DEBINOSWAP, COM_BUFF + 2 * i, 0, 2); up(&av7110->dcomlock); - return 0; + return 0; } int RequestParameter(struct av7110 *av7110, u16 tag, u16* Buff, s16 length) { int ret; - ret = CommandRequest(av7110, &tag, 0, Buff, length); + ret = CommandRequest(av7110, &tag, 0, Buff, length); if (ret) printk("RequestParameter error\n"); return ret; @@ -353,277 +513,351 @@ int RequestParameter(struct av7110 *av7110, u16 tag, u16* Buff, s16 length) * Firmware commands ****************************************************************************/ +/* get version of the firmware ROM, RTSL, video ucode and ARM application */ +void firmversion(struct av7110 *av7110) +{ + u16 buf[20]; + u16 tag = ((COMTYPE_REQUEST << 8) + ReqVersion); + + DEB_EE(("av7110: %p\n", av7110)); + + RequestParameter(av7110, tag, buf, 16); + + av7110->arm_fw = (buf[0] << 16) + buf[1]; + av7110->arm_rtsl = (buf[2] << 16) + buf[3]; + av7110->arm_vid = (buf[4] << 16) + buf[5]; + av7110->arm_app = (buf[6] << 16) + buf[7]; + av7110->avtype = (buf[8] << 16) + buf[9]; + + printk("DVB: AV711%d(%d) - firm %08x, rtsl %08x, vid %08x, app %08x\n", + av7110->avtype, av7110->dvb_adapter->num, av7110->arm_fw, + av7110->arm_rtsl, av7110->arm_vid, av7110->arm_app); + + /* print firmware capabilities */ + if (FW_CI_LL_SUPPORT(av7110->arm_app)) + printk("DVB: AV711%d(%d) - firmware supports CI link layer interface\n", + av7110->avtype, av7110->dvb_adapter->num); + else + printk("DVB: AV711%d(%d) - no firmware support for CI link layer interface\n", + av7110->avtype, av7110->dvb_adapter->num); + + return; +} + + +int SendDiSEqCMsg(struct av7110 *av7110, int len, u8 *msg, unsigned long burst) +{ + int i; + u16 buf[18] = { ((COMTYPE_AUDIODAC << 8) + SendDiSEqC), + 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + + DEB_EE(("av7110: %p\n", av7110)); + + if (len > 10) + len = 10; + + buf[1] = len + 2; + buf[2] = len; + + if (burst != -1) + buf[3] = burst ? 0x01 : 0x00; + else + buf[3] = 0xffff; + + for (i = 0; i < len; i++) + buf[i + 4] = msg[i]; + + if (SOutCommand(av7110, buf, 18)) + printk("SendDiSEqCMsg error\n"); + + return 0; +} + + #ifdef CONFIG_DVB_AV7110_OSD static inline int ResetBlend(struct av7110 *av7110, u8 windownr) { - return outcom(av7110, COMTYPE_OSD, SetNonBlend, 1, windownr); + return outcom(av7110, COMTYPE_OSD, SetNonBlend, 1, windownr); } static inline int SetColorBlend(struct av7110 *av7110, u8 windownr) { - return outcom(av7110, COMTYPE_OSD, SetCBlend, 1, windownr); + return outcom(av7110, COMTYPE_OSD, SetCBlend, 1, windownr); } static inline int SetWindowBlend(struct av7110 *av7110, u8 windownr, u8 blending) { - return outcom(av7110, COMTYPE_OSD, SetWBlend, 2, windownr, blending); + return outcom(av7110, COMTYPE_OSD, SetWBlend, 2, windownr, blending); } static inline int SetBlend_(struct av7110 *av7110, u8 windownr, - enum av7110_osd_palette_type colordepth, u16 index, u8 blending) + enum av7110_osd_palette_type colordepth, u16 index, u8 blending) { - return outcom(av7110, COMTYPE_OSD, SetBlend, 4, - windownr, colordepth, index, blending); + return outcom(av7110, COMTYPE_OSD, SetBlend, 4, + windownr, colordepth, index, blending); } static inline int SetColor_(struct av7110 *av7110, u8 windownr, - enum av7110_osd_palette_type colordepth, u16 index, u16 colorhi, u16 colorlo) + enum av7110_osd_palette_type colordepth, u16 index, u16 colorhi, u16 colorlo) { - return outcom(av7110, COMTYPE_OSD, SetColor, 5, - windownr, colordepth, index, colorhi, colorlo); + return outcom(av7110, COMTYPE_OSD, SetColor, 5, + windownr, colordepth, index, colorhi, colorlo); } static inline int BringToTop(struct av7110 *av7110, u8 windownr) { - return outcom(av7110, COMTYPE_OSD, WTop, 1, windownr); + return outcom(av7110, COMTYPE_OSD, WTop, 1, windownr); } static inline int SetFont(struct av7110 *av7110, u8 windownr, u8 fontsize, - u16 colorfg, u16 colorbg) + u16 colorfg, u16 colorbg) { - return outcom(av7110, COMTYPE_OSD, Set_Font, 4, - windownr, fontsize, colorfg, colorbg); + return outcom(av7110, COMTYPE_OSD, Set_Font, 4, + windownr, fontsize, colorfg, colorbg); } static int FlushText(struct av7110 *av7110) { - u32 start; + u32 start; - if (down_interruptible(&av7110->dcomlock)) + if (down_interruptible(&av7110->dcomlock)) return -ERESTARTSYS; - start = jiffies; - while ( rdebi(av7110, DEBINOSWAP, BUFF1_BASE, 0, 2 ) ) { - dvb_delay(1); - if ((jiffies - start) > ARM_WAIT_OSD) { - printk(KERN_ERR "%s: timeout waiting for BUFF1_BASE == 0\n", __FUNCTION__); - up(&av7110->dcomlock); - return -1; - } - } - up(&av7110->dcomlock); - return 0; + start = jiffies; + while (rdebi(av7110, DEBINOSWAP, BUFF1_BASE, 0, 2)) { + dvb_delay(1); + if (time_after(jiffies, start + ARM_WAIT_OSD)) { + printk(KERN_ERR "%s: timeout waiting for BUFF1_BASE == 0\n", + __FUNCTION__); + up(&av7110->dcomlock); + return -1; + } + } + up(&av7110->dcomlock); + return 0; } static int WriteText(struct av7110 *av7110, u8 win, u16 x, u16 y, u8* buf) { - int i, ret; - u32 start; - int length=strlen(buf)+1; - u16 cbuf[5] = { (COMTYPE_OSD<<8) + DText, 3, win, x, y }; + int i, ret; + u32 start; + int length = strlen(buf) + 1; + u16 cbuf[5] = { (COMTYPE_OSD << 8) + DText, 3, win, x, y }; - if (down_interruptible(&av7110->dcomlock)) + if (down_interruptible(&av7110->dcomlock)) return -ERESTARTSYS; - start = jiffies; - while ( rdebi(av7110, DEBINOSWAP, BUFF1_BASE, 0, 2 ) ) { - dvb_delay(1); - if ((jiffies - start) > ARM_WAIT_OSD) { - printk(KERN_ERR "%s: timeout waiting for BUFF1_BASE == 0\n", __FUNCTION__); - up(&av7110->dcomlock); - return -1; - } - } + start = jiffies; + while (rdebi(av7110, DEBINOSWAP, BUFF1_BASE, 0, 2)) { + dvb_delay(1); + if (time_after(jiffies, start + ARM_WAIT_OSD)) { + printk(KERN_ERR "%s: timeout waiting for BUFF1_BASE == 0\n", + __FUNCTION__); + up(&av7110->dcomlock); + return -1; + } + } #ifndef _NOHANDSHAKE - start = jiffies; - while ( rdebi(av7110, DEBINOSWAP, HANDSHAKE_REG, 0, 2 ) ) { - dvb_delay(1); - if ((jiffies - start) > ARM_WAIT_SHAKE) { - printk(KERN_ERR "%s: timeout waiting for HANDSHAKE_REG\n", __FUNCTION__); - up(&av7110->dcomlock); - return -1; - } - } + start = jiffies; + while (rdebi(av7110, DEBINOSWAP, HANDSHAKE_REG, 0, 2)) { + dvb_delay(1); + if (time_after(jiffies, start + ARM_WAIT_SHAKE)) { + printk(KERN_ERR "%s: timeout waiting for HANDSHAKE_REG\n", + __FUNCTION__); + up(&av7110->dcomlock); + return -1; + } + } #endif - for (i=0; i<length/2; i++) - wdebi(av7110, DEBINOSWAP, BUFF1_BASE + i*2, - swab16(*(u16 *)(buf+2*i)), 2); - if (length&1) - wdebi(av7110, DEBINOSWAP, BUFF1_BASE + i*2, 0, 2); - ret=OutCommand(av7110, cbuf, 5); - up(&av7110->dcomlock); + for (i = 0; i < length / 2; i++) + wdebi(av7110, DEBINOSWAP, BUFF1_BASE + i * 2, + swab16(*(u16 *)(buf + 2 * i)), 2); + if (length & 1) + wdebi(av7110, DEBINOSWAP, BUFF1_BASE + i * 2, 0, 2); + ret = OutCommand(av7110, cbuf, 5); + up(&av7110->dcomlock); if (ret) printk("WriteText error\n"); - return ret; + return ret; } static inline int DrawLine(struct av7110 *av7110, u8 windownr, - u16 x, u16 y, u16 dx, u16 dy, u16 color) + u16 x, u16 y, u16 dx, u16 dy, u16 color) { - return outcom(av7110, COMTYPE_OSD, DLine, 6, - windownr, x, y, dx, dy, color); + return outcom(av7110, COMTYPE_OSD, DLine, 6, + windownr, x, y, dx, dy, color); } static inline int DrawBlock(struct av7110 *av7110, u8 windownr, - u16 x, u16 y, u16 dx, u16 dy, u16 color) + u16 x, u16 y, u16 dx, u16 dy, u16 color) { - return outcom(av7110, COMTYPE_OSD, DBox, 6, - windownr, x, y, dx, dy, color); + return outcom(av7110, COMTYPE_OSD, DBox, 6, + windownr, x, y, dx, dy, color); } static inline int HideWindow(struct av7110 *av7110, u8 windownr) { - return outcom(av7110, COMTYPE_OSD, WHide, 1, windownr); + return outcom(av7110, COMTYPE_OSD, WHide, 1, windownr); } static inline int MoveWindowRel(struct av7110 *av7110, u8 windownr, u16 x, u16 y) { - return outcom(av7110, COMTYPE_OSD, WMoveD, 3, windownr, x, y); + return outcom(av7110, COMTYPE_OSD, WMoveD, 3, windownr, x, y); } static inline int MoveWindowAbs(struct av7110 *av7110, u8 windownr, u16 x, u16 y) { - return outcom(av7110, COMTYPE_OSD, WMoveA, 3, windownr, x, y); + return outcom(av7110, COMTYPE_OSD, WMoveA, 3, windownr, x, y); } static inline int DestroyOSDWindow(struct av7110 *av7110, u8 windownr) { - return outcom(av7110, COMTYPE_OSD, WDestroy, 1, windownr); + return outcom(av7110, COMTYPE_OSD, WDestroy, 1, windownr); } static inline int CreateOSDWindow(struct av7110 *av7110, u8 windownr, - enum av7110_window_display_type disptype, u16 width, u16 height) + enum av7110_window_display_type disptype, + u16 width, u16 height) { - return outcom(av7110, COMTYPE_OSD, WCreate, 4, - windownr, disptype, width, height); + return outcom(av7110, COMTYPE_OSD, WCreate, 4, + windownr, disptype, width, height); } -static enum av7110_osd_palette_type bpp2pal[8]={Pal1Bit, Pal2Bit, 0, Pal4Bit, 0, 0, 0, Pal8Bit}; -static enum av7110_window_display_type bpp2bit[8]={BITMAP1, BITMAP2, 0, BITMAP4, 0, 0, 0, BITMAP8}; +static enum av7110_osd_palette_type bpp2pal[8] = { + Pal1Bit, Pal2Bit, 0, Pal4Bit, 0, 0, 0, Pal8Bit +}; +static enum av7110_window_display_type bpp2bit[8] = { + BITMAP1, BITMAP2, 0, BITMAP4, 0, 0, 0, BITMAP8 +}; -static inline int LoadBitmap(struct av7110 *av7110, u16 format, u16 dx, u16 dy, int inc, u8* data) +static inline int LoadBitmap(struct av7110 *av7110, u16 format, + u16 dx, u16 dy, int inc, u8* data) { - int bpp; - int i; - int d, delta; - u8 c; - DECLARE_WAITQUEUE(wait, current); + int bpp; + int i; + int d, delta; + u8 c; + DECLARE_WAITQUEUE(wait, current); - DEB_EE(("av7110: %p\n",av7110)); + DEB_EE(("av7110: %p\n", av7110)); - if (av7110->bmp_state==BMP_LOADING) { - add_wait_queue(&av7110->bmpq, &wait); - while (1) { - set_current_state(TASK_INTERRUPTIBLE); - if (av7110->bmp_state!=BMP_LOADING - || signal_pending(current)) - break; - schedule(); - } - set_current_state(TASK_RUNNING); - remove_wait_queue(&av7110->bmpq, &wait); - } - if (av7110->bmp_state==BMP_LOADING) - return -1; - av7110->bmp_state=BMP_LOADING; - if (format==BITMAP8) { bpp=8; delta = 1; } - else if (format==BITMAP4) { bpp=4; delta = 2; } - else if (format==BITMAP2) { bpp=2; delta = 4; } - else if (format==BITMAP1) { bpp=1; delta = 8; } - else { - av7110->bmp_state=BMP_NONE; - return -1; - } - av7110->bmplen= ((dx*dy*bpp+7)&~7)/8; - av7110->bmpp=0; - if (av7110->bmplen>32768) { - av7110->bmp_state=BMP_NONE; - return -1; - } - for (i=0; i<dy; i++) { - if (copy_from_user(av7110->bmpbuf+1024+i*dx, data+i*inc, dx)) { - av7110->bmp_state=BMP_NONE; - return -1; - } - } - if (format != BITMAP8) { - for (i=0; i<dx*dy/delta; i++) { - c = ((u8 *)av7110->bmpbuf)[1024+i*delta+delta-1]; - for (d=delta-2; d>=0; d--) { - c |= (((u8 *)av7110->bmpbuf)[1024+i*delta+d] - << ((delta-d-1)*bpp)); - ((u8 *)av7110->bmpbuf)[1024+i] = c; - } - } - } - av7110->bmplen+=1024; - return outcom(av7110, COMTYPE_OSD, LoadBmp, 3, format, dx, dy); + if (av7110->bmp_state == BMP_LOADING) { + add_wait_queue(&av7110->bmpq, &wait); + while (1) { + set_current_state(TASK_INTERRUPTIBLE); + if (av7110->bmp_state != BMP_LOADING + || signal_pending(current)) + break; + schedule(); + } + set_current_state(TASK_RUNNING); + remove_wait_queue(&av7110->bmpq, &wait); + } + if (av7110->bmp_state == BMP_LOADING) + return -1; + av7110->bmp_state = BMP_LOADING; + if (format == BITMAP8) { + bpp=8; delta = 1; + } else if (format == BITMAP4) { + bpp=4; delta = 2; + } else if (format == BITMAP2) { + bpp=2; delta = 4; + } else if (format == BITMAP1) { + bpp=1; delta = 8; + } else { + av7110->bmp_state = BMP_NONE; + return -1; + } + av7110->bmplen = ((dx * dy * bpp + 7) & ~7) / 8; + av7110->bmpp = 0; + if (av7110->bmplen > 32768) { + av7110->bmp_state = BMP_NONE; + return -1; + } + for (i = 0; i < dy; i++) { + if (copy_from_user(av7110->bmpbuf + 1024 + i * dx, data + i * inc, dx)) { + av7110->bmp_state = BMP_NONE; + return -1; + } + } + if (format != BITMAP8) { + for (i = 0; i < dx * dy / delta; i++) { + c = ((u8 *)av7110->bmpbuf)[1024 + i * delta + delta - 1]; + for (d = delta - 2; d >= 0; d--) { + c |= (((u8 *)av7110->bmpbuf)[1024 + i * delta + d] + << ((delta - d - 1) * bpp)); + ((u8 *)av7110->bmpbuf)[1024 + i] = c; + } + } + } + av7110->bmplen += 1024; + return outcom(av7110, COMTYPE_OSD, LoadBmp, 3, format, dx, dy); } static int BlitBitmap(struct av7110 *av7110, u16 win, u16 x, u16 y, u16 trans) { - DECLARE_WAITQUEUE(wait, current); + DECLARE_WAITQUEUE(wait, current); - DEB_EE(("av7110: %p\n",av7110)); + DEB_EE(("av7110: %p\n", av7110)); + + if (av7110->bmp_state == BMP_NONE) + return -1; + if (av7110->bmp_state == BMP_LOADING) { + add_wait_queue(&av7110->bmpq, &wait); + while (1) { + set_current_state(TASK_INTERRUPTIBLE); + if (av7110->bmp_state != BMP_LOADING + || signal_pending(current)) + break; + schedule(); + } + set_current_state(TASK_RUNNING); + remove_wait_queue(&av7110->bmpq, &wait); + } + if (av7110->bmp_state == BMP_LOADED) + return outcom(av7110, COMTYPE_OSD, BlitBmp, 4, win, x, y, trans); + return -1; +} - if (av7110->bmp_state==BMP_NONE) - return -1; - if (av7110->bmp_state==BMP_LOADING) { - add_wait_queue(&av7110->bmpq, &wait); - while (1) { - set_current_state(TASK_INTERRUPTIBLE); - if (av7110->bmp_state!=BMP_LOADING - || signal_pending(current)) - break; - schedule(); - } - set_current_state(TASK_RUNNING); - remove_wait_queue(&av7110->bmpq, &wait); - } - if (av7110->bmp_state==BMP_LOADED) - return outcom(av7110, COMTYPE_OSD, BlitBmp, 4, win, x, y, trans); - return -1; -} - -static inline int ReleaseBitmap(struct av7110 *av7110) +static inline int ReleaseBitmap(struct av7110 *av7110) { DEB_EE(("av7110: %p\n",av7110)); - if (av7110->bmp_state!=BMP_LOADED) - return -1; - av7110->bmp_state=BMP_NONE; - return outcom(av7110, COMTYPE_OSD, ReleaseBmp, 0); + if (av7110->bmp_state != BMP_LOADED) + return -1; + av7110->bmp_state = BMP_NONE; + return outcom(av7110, COMTYPE_OSD, ReleaseBmp, 0); } static u32 RGB2YUV(u16 R, u16 G, u16 B) { - u16 y, u, v; - u16 Y, Cr, Cb; + u16 y, u, v; + u16 Y, Cr, Cb; - y = R * 77 + G * 150 + B * 29; // Luma=0.299R+0.587G+0.114B 0..65535 - u = 2048+B * 8 -(y>>5); // Cr 0..4095 - v = 2048+R * 8 -(y>>5); // Cb 0..4095 + y = R * 77 + G * 150 + B * 29; /* Luma=0.299R+0.587G+0.114B 0..65535 */ + u = 2048 + B * 8 -(y >> 5); /* Cr 0..4095 */ + v = 2048 + R * 8 -(y >> 5); /* Cb 0..4095 */ - Y=y/256; - Cb=u/16; - Cr=v/16; + Y = y / 256; + Cb = u / 16; + Cr = v / 16; - return Cr|(Cb<<16)|(Y<<8); + return Cr | (Cb << 16) | (Y << 8); } static void OSDSetColor(struct av7110 *av7110, u8 color, u8 r, u8 g, u8 b, u8 blend) { - u16 ch, cl; - u32 yuv; + u16 ch, cl; + u32 yuv; - yuv=blend ? RGB2YUV(r,g,b) : 0; - cl=(yuv&0xffff); - ch=((yuv>>16)&0xffff); - SetColor_(av7110, av7110->osdwin, bpp2pal[av7110->osdbpp[av7110->osdwin]], - color, ch, cl); - SetBlend_(av7110, av7110->osdwin, bpp2pal[av7110->osdbpp[av7110->osdwin]], - color, ((blend>>4)&0x0f)); + yuv = blend ? RGB2YUV(r,g,b) : 0; + cl = (yuv & 0xffff); + ch = ((yuv >> 16) & 0xffff); + SetColor_(av7110, av7110->osdwin, bpp2pal[av7110->osdbpp[av7110->osdwin]], + color, ch, cl); + SetBlend_(av7110, av7110->osdwin, bpp2pal[av7110->osdbpp[av7110->osdwin]], + color, ((blend >> 4) & 0x0f)); } static int OSDSetPalette(struct av7110 *av7110, u32 *colors, u8 first, u8 last) @@ -632,378 +866,158 @@ static int OSDSetPalette(struct av7110 *av7110, u32 *colors, u8 first, u8 last) int length = last - first + 1; if (length * 4 > DATA_BUFF3_SIZE) - return -1; - - for (i=0; i<length; i++) { - u32 blend = (colors[i] & 0xF0000000) >> 4; - u32 yuv = blend ? RGB2YUV(colors[i] & 0xFF, (colors[i] >> 8) & 0xFF, (colors[i] >> 16) & 0xFF) | blend : 0; - yuv = ((yuv & 0xFFFF0000) >> 16) | ((yuv & 0x0000FFFF) << 16); - wdebi(av7110, DEBINOSWAP, DATA_BUFF3_BASE + i*4, yuv, 4); + return -1; + + for (i = 0; i < length; i++) { + u32 blend = (colors[i] & 0xF0000000) >> 4; + u32 yuv = blend ? RGB2YUV(colors[i] & 0xFF, (colors[i] >> 8) & 0xFF, + (colors[i] >> 16) & 0xFF) | blend : 0; + yuv = ((yuv & 0xFFFF0000) >> 16) | ((yuv & 0x0000FFFF) << 16); + wdebi(av7110, DEBINOSWAP, DATA_BUFF3_BASE + i * 4, yuv, 4); } return outcom(av7110, COMTYPE_OSD, Set_Palette, 4, - av7110->osdwin, bpp2pal[av7110->osdbpp[av7110->osdwin]], first, last); -} - -static int OSDSetBlock(struct av7110 *av7110, int x0, int y0, int x1, int y1, int inc, u8 *data) -{ - uint w, h, bpp, bpl, size, lpb, bnum, brest; - int i; - - w=x1-x0+1; h=y1-y0+1; - if (inc<=0) - inc=w; - if (w<=0 || w>720 || h<=0 || h>576) - return -1; - bpp=av7110->osdbpp[av7110->osdwin]+1; - bpl=((w*bpp+7)&~7)/8; - size=h*bpl; - lpb=(32*1024)/bpl; - bnum=size/(lpb*bpl); - brest=size-bnum*lpb*bpl; - - for (i=0; i<bnum; i++) { - LoadBitmap(av7110, bpp2bit[av7110->osdbpp[av7110->osdwin]], w, lpb, inc, data); - BlitBitmap(av7110, av7110->osdwin, x0, y0+i*lpb, 0); - data+=lpb*inc; - } - if (brest) { - LoadBitmap(av7110, bpp2bit[av7110->osdbpp[av7110->osdwin]], w, brest/bpl, inc, data); - BlitBitmap(av7110, av7110->osdwin, x0, y0+bnum*lpb, 0); - } - ReleaseBitmap(av7110); - return 0; + av7110->osdwin, bpp2pal[av7110->osdbpp[av7110->osdwin]], + first, last); } -int OSD_DrawCommand(struct av7110 *av7110, osd_cmd_t *dc) +static int OSDSetBlock(struct av7110 *av7110, int x0, int y0, + int x1, int y1, int inc, u8 *data) { - switch (dc->cmd) { - case OSD_Close: - DestroyOSDWindow(av7110, av7110->osdwin); - return 0; - case OSD_Open: - av7110->osdbpp[av7110->osdwin]=(dc->color-1)&7; - CreateOSDWindow(av7110, av7110->osdwin, bpp2bit[av7110->osdbpp[av7110->osdwin]], - dc->x1-dc->x0+1, dc->y1-dc->y0+1); - if (!dc->data) { - MoveWindowAbs(av7110, av7110->osdwin, dc->x0, dc->y0); - SetColorBlend(av7110, av7110->osdwin); - } - return 0; - case OSD_Show: - MoveWindowRel(av7110, av7110->osdwin, 0, 0); - return 0; - case OSD_Hide: - HideWindow(av7110, av7110->osdwin); - return 0; - case OSD_Clear: - DrawBlock(av7110, av7110->osdwin, 0, 0, 720, 576, 0); - return 0; - case OSD_Fill: - DrawBlock(av7110, av7110->osdwin, 0, 0, 720, 576, dc->color); - return 0; - case OSD_SetColor: - OSDSetColor(av7110, dc->color, dc->x0, dc->y0, dc->x1, dc->y1); - return 0; - case OSD_SetPalette: - { - if (FW_VERSION(av7110->arm_app) >= 0x2618) - OSDSetPalette(av7110, (u32 *)dc->data, dc->color, dc->x0); - else { - int i, len=dc->x0-dc->color+1; - u8 *colors=(u8 *)dc->data; - - for (i=0; i<len; i++) - OSDSetColor(av7110, dc->color+i, - colors[i*4] , colors[i*4+1], - colors[i*4+2], colors[i*4+3]); - } - return 0; - } - case OSD_SetTrans: - return 0; - case OSD_SetPixel: - DrawLine(av7110, av7110->osdwin, - dc->x0, dc->y0, 0, 0, - dc->color); - return 0; - case OSD_GetPixel: - return 0; - - case OSD_SetRow: - dc->y1=dc->y0; - case OSD_SetBlock: - OSDSetBlock(av7110, dc->x0, dc->y0, dc->x1, dc->y1, dc->color, dc->data); - return 0; - - case OSD_FillRow: - DrawBlock(av7110, av7110->osdwin, dc->x0, dc->y0, - dc->x1-dc->x0+1, dc->y1, - dc->color); - return 0; - case OSD_FillBlock: - DrawBlock(av7110, av7110->osdwin, dc->x0, dc->y0, - dc->x1-dc->x0+1, dc->y1-dc->y0+1, - dc->color); - return 0; - case OSD_Line: - DrawLine(av7110, av7110->osdwin, - dc->x0, dc->y0, dc->x1-dc->x0, dc->y1-dc->y0, - dc->color); - return 0; - case OSD_Query: - return 0; - case OSD_Test: - return 0; - case OSD_Text: - { - char textbuf[240]; - - if (strncpy_from_user(textbuf, dc->data, 240)<0) - return -EFAULT; - textbuf[239]=0; - if (dc->x1>3) - dc->x1=3; - SetFont(av7110, av7110->osdwin, dc->x1, - (u16) (dc->color&0xffff), (u16) (dc->color>>16)); - FlushText(av7110); - WriteText(av7110, av7110->osdwin, dc->x0, dc->y0, textbuf); - return 0; - } - case OSD_SetWindow: - if (dc->x0<1 || dc->x0>7) - return -EINVAL; - av7110->osdwin=dc->x0; - return 0; - case OSD_MoveWindow: - MoveWindowAbs(av7110, av7110->osdwin, dc->x0, dc->y0); - SetColorBlend(av7110, av7110->osdwin); - return 0; - default: - return -EINVAL; - } -} -#endif /* CONFIG_DVB_AV7110_OSD */ - + uint w, h, bpp, bpl, size, lpb, bnum, brest; + int i; -/* get version of the firmware ROM, RTSL, video ucode and ARM application */ -void firmversion(struct av7110 *av7110) -{ - u16 buf[20]; - u16 tag = ((COMTYPE_REQUEST << 8) + ReqVersion); - - DEB_EE(("av7110: %p\n",av7110)); - - RequestParameter(av7110, tag, buf, 16); - - av7110->arm_fw=(buf[0] << 16) + buf[1]; - av7110->arm_rtsl=(buf[2] << 16) + buf[3]; - av7110->arm_vid=(buf[4] << 16) + buf[5]; - av7110->arm_app=(buf[6] << 16) + buf[7]; - av7110->avtype=(buf[8] << 16) + buf[9]; - - printk ("DVB: AV711%d(%d) - firm %08x, rtsl %08x, vid %08x, app %08x\n", - av7110->avtype, av7110->dvb_adapter->num, av7110->arm_fw, - av7110->arm_rtsl, av7110->arm_vid, av7110->arm_app); - - /* print firmware capabilities */ - if (FW_CI_LL_SUPPORT(av7110->arm_app)) - printk ("DVB: AV711%d(%d) - firmware supports CI link layer interface\n", - av7110->avtype, av7110->dvb_adapter->num); - else - printk ("DVB: AV711%d(%d) - no firmware support for CI link layer interface\n", - av7110->avtype, av7110->dvb_adapter->num); - - return; -} - -static int waitdebi(struct av7110 *av7110, int adr, int state) -{ - int k; - - DEB_EE(("av7110: %p\n",av7110)); - - for (k=0; k<100; k++, udelay(500)) { - if (irdebi(av7110, DEBINOSWAP, adr, 0, 2) == state) - return 0; - } - return -1; -} - -static int load_dram(struct av7110 *av7110, u32 *data, int len) -{ - int i; - int blocks, rest; - u32 base, bootblock=BOOT_BLOCK; - - DEB_EE(("av7110: %p\n",av7110)); - - blocks=len/BOOT_MAX_SIZE; - rest=len % BOOT_MAX_SIZE; - base=DRAM_START_CODE; - - for (i=0; i<blocks; i++) { - if (waitdebi(av7110, BOOT_STATE, BOOTSTATE_BUFFER_EMPTY) < 0) - return -1; - DEB_D(("Writing DRAM block %d\n",i)); - mwdebi(av7110, DEBISWAB, bootblock, - ((char*)data) + i*(BOOT_MAX_SIZE), - BOOT_MAX_SIZE); - bootblock^=0x1400; - iwdebi(av7110, DEBISWAB, BOOT_BASE, swab32(base), 4); - iwdebi(av7110, DEBINOSWAP, BOOT_SIZE, BOOT_MAX_SIZE, 2); - iwdebi(av7110, DEBINOSWAP, BOOT_STATE, BOOTSTATE_BUFFER_FULL, 2); - base+=BOOT_MAX_SIZE; - } - - if (rest > 0) { - if (waitdebi(av7110, BOOT_STATE, BOOTSTATE_BUFFER_EMPTY) < 0) - return -1; - if (rest>4) - mwdebi(av7110, DEBISWAB, bootblock, ((char*)data) + i*(BOOT_MAX_SIZE), rest); - else - mwdebi(av7110, DEBISWAB, bootblock, ((char*)data) + i*(BOOT_MAX_SIZE) - 4, rest+4); - - iwdebi(av7110, DEBISWAB, BOOT_BASE, swab32(base), 4); - iwdebi(av7110, DEBINOSWAP, BOOT_SIZE, rest, 2); - iwdebi(av7110, DEBINOSWAP, BOOT_STATE, BOOTSTATE_BUFFER_FULL, 2); - } - if (waitdebi(av7110, BOOT_STATE, BOOTSTATE_BUFFER_EMPTY) < 0) - return -1; - iwdebi(av7110, DEBINOSWAP, BOOT_SIZE, 0, 2); - iwdebi(av7110, DEBINOSWAP, BOOT_STATE, BOOTSTATE_BUFFER_FULL, 2); - if (waitdebi(av7110, BOOT_STATE, BOOTSTATE_BOOT_COMPLETE) < 0) - return -1; - return 0; -} - - -static u8 bootcode[] = { - 0xea, 0x00, 0x00, 0x0e, 0xe1, 0xb0, 0xf0, 0x0e, /* 0x0000 */ - 0xe2, 0x5e, 0xf0, 0x04, 0xe2, 0x5e, 0xf0, 0x04, - 0xe2, 0x5e, 0xf0, 0x08, 0xe2, 0x5e, 0xf0, 0x04, - 0xe2, 0x5e, 0xf0, 0x04, 0xe2, 0x5e, 0xf0, 0x04, - 0x2c, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x0c, - 0x00, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x34, - 0x00, 0x00, 0x00, 0x00, 0xa5, 0xa5, 0x5a, 0x5a, - 0x00, 0x1f, 0x15, 0x55, 0x00, 0x00, 0x00, 0x09, - 0xe5, 0x9f, 0xd0, 0x5c, 0xe5, 0x9f, 0x40, 0x54, /* 0x0040 */ - 0xe3, 0xa0, 0x00, 0x00, 0xe5, 0x84, 0x00, 0x00, - 0xe5, 0x84, 0x00, 0x04, 0xe1, 0xd4, 0x10, 0xb0, - 0xe3, 0x51, 0x00, 0x00, 0x0a, 0xff, 0xff, 0xfc, - 0xe1, 0xa0, 0x10, 0x0d, 0xe5, 0x94, 0x30, 0x04, - 0xe1, 0xd4, 0x20, 0xb2, 0xe2, 0x82, 0x20, 0x3f, - 0xe1, 0xb0, 0x23, 0x22, 0x03, 0xa0, 0x00, 0x02, - 0xe1, 0xc4, 0x00, 0xb0, 0x0a, 0xff, 0xff, 0xf4, - 0xe8, 0xb1, 0x1f, 0xe0, 0xe8, 0xa3, 0x1f, 0xe0, /* 0x0080 */ - 0xe8, 0xb1, 0x1f, 0xe0, 0xe8, 0xa3, 0x1f, 0xe0, - 0xe2, 0x52, 0x20, 0x01, 0x1a, 0xff, 0xff, 0xf9, - 0xe2, 0x2d, 0xdb, 0x05, 0xea, 0xff, 0xff, 0xec, - 0x2c, 0x00, 0x03, 0xf8, 0x2c, 0x00, 0x04, 0x00, -}; - -int bootarm(struct av7110 *av7110) -{ - struct saa7146_dev *dev= av7110->dev; - u32 ret; - int i; - - DEB_EE(("av7110: %p\n",av7110)); - - saa7146_setgpio(dev, RESET_LINE, SAA7146_GPIO_OUTLO); - - /* Disable DEBI and GPIO irq */ - IER_DISABLE(av7110->dev, MASK_03|MASK_19); -/* - saa7146_write(av7110->dev, IER, - saa7146_read(av7110->dev, IER) & - ~(MASK_19 | MASK_03)); -*/ - saa7146_write(av7110->dev, ISR, (MASK_19 | MASK_03)); - - /* enable DEBI */ - saa7146_write(av7110->dev, MC1, 0x08800880); - saa7146_write(av7110->dev, DD1_STREAM_B, 0x00000000); - saa7146_write(av7110->dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26)); - - /* test DEBI */ - iwdebi(av7110, DEBISWAP, DPRAM_BASE, 0x76543210, 4); - if ((ret=irdebi(av7110, DEBINOSWAP, DPRAM_BASE, 0, 4))!=0x10325476) { - printk(KERN_ERR "dvb: debi test in bootarm() failed: " - "%08x != %08x\n", ret, 0x10325476);; - return -1; - } - for (i=0; i<8192; i+=4) - iwdebi(av7110, DEBISWAP, DPRAM_BASE+i, 0x00, 4); - DEB_D(("bootarm: debi test OK\n")); - - /* boot */ - DEB_D(("bootarm: load boot code\n")); - - saa7146_setgpio(dev, ARM_IRQ_LINE, SAA7146_GPIO_IRQLO); - //saa7146_setgpio(dev, DEBI_DONE_LINE, SAA7146_GPIO_INPUT); - //saa7146_setgpio(dev, 3, SAA7146_GPIO_INPUT); - - mwdebi(av7110, DEBISWAB, DPRAM_BASE, bootcode, sizeof(bootcode)); - iwdebi(av7110, DEBINOSWAP, BOOT_STATE, BOOTSTATE_BUFFER_FULL, 2); - - saa7146_wait_for_debi_done(av7110->dev); - saa7146_setgpio(dev, RESET_LINE, SAA7146_GPIO_OUTHI); - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(HZ); - - DEB_D(("bootarm: load dram code\n")); - - if (load_dram(av7110, (u32 *)av7110->bin_root, av7110->size_root)<0) + w = x1 - x0 + 1; + h = y1 - y0 + 1; + if (inc <= 0) + inc = w; + if (w <= 0 || w > 720 || h <= 0 || h > 576) return -1; - - saa7146_setgpio(dev, RESET_LINE, SAA7146_GPIO_OUTLO); - mdelay(1); - - DEB_D(("bootarm: load dpram code\n")); - - mwdebi(av7110, DEBISWAB, DPRAM_BASE, av7110->bin_dpram, av7110->size_dpram); - - saa7146_wait_for_debi_done(av7110->dev); - - saa7146_setgpio(dev, RESET_LINE, SAA7146_GPIO_OUTHI); - mdelay(800); - - //ARM_ClearIrq(av7110); - ARM_ResetMailBox(av7110); - saa7146_write(av7110->dev, ISR, (MASK_19 | MASK_03)); - IER_ENABLE(av7110->dev, MASK_03); -// saa7146_write(av7110->dev, IER, -// saa7146_read(av7110->dev, IER) | MASK_03 ); - - av7110->arm_errors=0; - av7110->arm_ready=1; - return 0; + bpp = av7110->osdbpp[av7110->osdwin] + 1; + bpl = ((w * bpp + 7) & ~7) / 8; + size = h * bpl; + lpb = (32 * 1024) / bpl; + bnum = size / (lpb * bpl); + brest = size - bnum * lpb * bpl; + + for (i = 0; i < bnum; i++) { + LoadBitmap(av7110, bpp2bit[av7110->osdbpp[av7110->osdwin]], + w, lpb, inc, data); + BlitBitmap(av7110, av7110->osdwin, x0, y0 + i * lpb, 0); + data += lpb * inc; + } + if (brest) { + LoadBitmap(av7110, bpp2bit[av7110->osdbpp[av7110->osdwin]], + w, brest / bpl, inc, data); + BlitBitmap(av7110, av7110->osdwin, x0, y0 + bnum * lpb, 0); + } + ReleaseBitmap(av7110); + return 0; } -int SendDiSEqCMsg(struct av7110 *av7110, int len, u8 *msg, unsigned long burst) +int OSD_DrawCommand(struct av7110 *av7110, osd_cmd_t *dc) { - int i; - u16 buf[18] = { ((COMTYPE_AUDIODAC << 8) + SendDiSEqC), - 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - - DEB_EE(("av7110: %p\n",av7110)); - - if (len>10) - len=10; - - buf[1] = len+2; - buf[2] = len; - - if (burst!=-1) - buf[3]=burst ? 0x01 : 0x00; - else - buf[3]=0xffff; - - for (i=0; i<len; i++) - buf[i+4]=msg[i]; + switch (dc->cmd) { + case OSD_Close: + DestroyOSDWindow(av7110, av7110->osdwin); + return 0; + case OSD_Open: + av7110->osdbpp[av7110->osdwin] = (dc->color - 1) & 7; + CreateOSDWindow(av7110, av7110->osdwin, + bpp2bit[av7110->osdbpp[av7110->osdwin]], + dc->x1 - dc->x0 + 1, dc->y1 - dc->y0 + 1); + if (!dc->data) { + MoveWindowAbs(av7110, av7110->osdwin, dc->x0, dc->y0); + SetColorBlend(av7110, av7110->osdwin); + } + return 0; + case OSD_Show: + MoveWindowRel(av7110, av7110->osdwin, 0, 0); + return 0; + case OSD_Hide: + HideWindow(av7110, av7110->osdwin); + return 0; + case OSD_Clear: + DrawBlock(av7110, av7110->osdwin, 0, 0, 720, 576, 0); + return 0; + case OSD_Fill: + DrawBlock(av7110, av7110->osdwin, 0, 0, 720, 576, dc->color); + return 0; + case OSD_SetColor: + OSDSetColor(av7110, dc->color, dc->x0, dc->y0, dc->x1, dc->y1); + return 0; + case OSD_SetPalette: + { + if (FW_VERSION(av7110->arm_app) >= 0x2618) + OSDSetPalette(av7110, (u32 *)dc->data, dc->color, dc->x0); + else { + int i, len = dc->x0-dc->color+1; + u8 *colors = (u8 *)dc->data; + + for (i = 0; i<len; i++) + OSDSetColor(av7110, dc->color + i, + colors[i * 4], colors[i * 4 + 1], + colors[i * 4 + 2], colors[i * 4 + 3]); + } + return 0; + } + case OSD_SetTrans: + return 0; + case OSD_SetPixel: + DrawLine(av7110, av7110->osdwin, + dc->x0, dc->y0, 0, 0, dc->color); + return 0; + case OSD_GetPixel: + return 0; - if (SOutCommand(av7110, buf, 18)) - printk("SendDiSEqCMsg error\n"); + case OSD_SetRow: + dc->y1 = dc->y0; + /* fall through */ + case OSD_SetBlock: + OSDSetBlock(av7110, dc->x0, dc->y0, dc->x1, dc->y1, dc->color, dc->data); + return 0; - return 0; + case OSD_FillRow: + DrawBlock(av7110, av7110->osdwin, dc->x0, dc->y0, + dc->x1-dc->x0+1, dc->y1, dc->color); + return 0; + case OSD_FillBlock: + DrawBlock(av7110, av7110->osdwin, dc->x0, dc->y0, + dc->x1 - dc->x0 + 1, dc->y1 - dc->y0 + 1, dc->color); + return 0; + case OSD_Line: + DrawLine(av7110, av7110->osdwin, + dc->x0, dc->y0, dc->x1 - dc->x0, dc->y1 - dc->y0, dc->color); + return 0; + case OSD_Query: + return 0; + case OSD_Test: + return 0; + case OSD_Text: + { + char textbuf[240]; + + if (strncpy_from_user(textbuf, dc->data, 240) < 0) + return -EFAULT; + textbuf[239] = 0; + if (dc->x1 > 3) + dc->x1 = 3; + SetFont(av7110, av7110->osdwin, dc->x1, + (u16) (dc->color & 0xffff), (u16) (dc->color >> 16)); + FlushText(av7110); + WriteText(av7110, av7110->osdwin, dc->x0, dc->y0, textbuf); + return 0; + } + case OSD_SetWindow: + if (dc->x0 < 1 || dc->x0 > 7) + return -EINVAL; + av7110->osdwin = dc->x0; + return 0; + case OSD_MoveWindow: + MoveWindowAbs(av7110, av7110->osdwin, dc->x0, dc->y0); + SetColorBlend(av7110, av7110->osdwin); + return 0; + default: + return -EINVAL; + } } +#endif /* CONFIG_DVB_AV7110_OSD */ diff --git a/linux/drivers/media/dvb/ttpci/av7110_hw.h b/linux/drivers/media/dvb/ttpci/av7110_hw.h index 915c3aef2..06664581f 100644 --- a/linux/drivers/media/dvb/ttpci/av7110_hw.h +++ b/linux/drivers/media/dvb/ttpci/av7110_hw.h @@ -32,70 +32,72 @@ enum av7110_type_rec_play_format enum av7110_osd_palette_type { - NoPalet = 0, /* No palette */ - Pal1Bit = 2, /* 2 colors for 1 Bit Palette */ - Pal2Bit = 4, /* 4 colors for 2 bit palette */ - Pal4Bit = 16, /* 16 colors for 4 bit palette */ - Pal8Bit = 256 /* 256 colors for 16 bit palette */ + NoPalet = 0, /* No palette */ + Pal1Bit = 2, /* 2 colors for 1 Bit Palette */ + Pal2Bit = 4, /* 4 colors for 2 bit palette */ + Pal4Bit = 16, /* 16 colors for 4 bit palette */ + Pal8Bit = 256 /* 256 colors for 16 bit palette */ }; enum av7110_window_display_type { - BITMAP1, /* 1 bit bitmap */ - BITMAP2, /* 2 bit bitmap */ - BITMAP4, /* 4 bit bitmap */ - BITMAP8, /* 8 bit bitmap */ - BITMAP1HR, /* 1 Bit bitmap half resolution */ - BITMAP2HR, /* 2 bit bitmap half resolution */ - BITMAP4HR, /* 4 bit bitmap half resolution */ - BITMAP8HR, /* 8 bit bitmap half resolution */ - YCRCB422, /* 4:2:2 YCRCB Graphic Display */ - YCRCB444, /* 4:4:4 YCRCB Graphic Display */ - YCRCB444HR, /* 4:4:4 YCRCB graphic half resolution */ - VIDEOTSIZE, /* True Size Normal MPEG Video Display */ - VIDEOHSIZE, /* MPEG Video Display Half Resolution */ - VIDEOQSIZE, /* MPEG Video Display Quarter Resolution */ - VIDEODSIZE, /* MPEG Video Display Double Resolution */ - VIDEOTHSIZE, /* True Size MPEG Video Display Half Resolution */ - VIDEOTQSIZE, /* True Size MPEG Video Display Quarter Resolution*/ - VIDEOTDSIZE, /* True Size MPEG Video Display Double Resolution */ - VIDEONSIZE, /* Full Size MPEG Video Display */ - CURSOR /* Cursor */ + BITMAP1, /* 1 bit bitmap */ + BITMAP2, /* 2 bit bitmap */ + BITMAP4, /* 4 bit bitmap */ + BITMAP8, /* 8 bit bitmap */ + BITMAP1HR, /* 1 Bit bitmap half resolution */ + BITMAP2HR, /* 2 bit bitmap half resolution */ + BITMAP4HR, /* 4 bit bitmap half resolution */ + BITMAP8HR, /* 8 bit bitmap half resolution */ + YCRCB422, /* 4:2:2 YCRCB Graphic Display */ + YCRCB444, /* 4:4:4 YCRCB Graphic Display */ + YCRCB444HR, /* 4:4:4 YCRCB graphic half resolution */ + VIDEOTSIZE, /* True Size Normal MPEG Video Display */ + VIDEOHSIZE, /* MPEG Video Display Half Resolution */ + VIDEOQSIZE, /* MPEG Video Display Quarter Resolution */ + VIDEODSIZE, /* MPEG Video Display Double Resolution */ + VIDEOTHSIZE, /* True Size MPEG Video Display Half Resolution */ + VIDEOTQSIZE, /* True Size MPEG Video Display Quarter Resolution*/ + VIDEOTDSIZE, /* True Size MPEG Video Display Double Resolution */ + VIDEONSIZE, /* Full Size MPEG Video Display */ + CURSOR /* Cursor */ }; /* switch defines */ #define SB_GPIO 3 -#define SB_OFF SAA7146_GPIO_OUTLO //SlowBlank aus (TV-Mode) -#define SB_ON SAA7146_GPIO_INPUT //SlowBlank an (AV-Mode) -#define SB_WIDE SAA7146_GPIO_OUTHI //SlowBlank 6V (16/9-Mode) nicht realisiert +#define SB_OFF SAA7146_GPIO_OUTLO /* SlowBlank off (TV-Mode) */ +#define SB_ON SAA7146_GPIO_INPUT /* SlowBlank on (AV-Mode) */ +#define SB_WIDE SAA7146_GPIO_OUTHI /* SlowBlank 6V (16/9-Mode) (not implemented) */ #define FB_GPIO 1 -#define FB_OFF SAA7146_GPIO_LO //FastBlank aus (CVBS-Mode) -#define FB_ON SAA7146_GPIO_OUTHI //FastBlank an (RGB-Mode) -#define FB_LOOP SAA7146_GPIO_INPUT //FastBlank der PC-Grafik durchschleifen +#define FB_OFF SAA7146_GPIO_LO /* FastBlank off (CVBS-Mode) */ +#define FB_ON SAA7146_GPIO_OUTHI /* FastBlank on (RGB-Mode) */ +#define FB_LOOP SAA7146_GPIO_INPUT /* FastBlank loop-through (PC graphics ???) */ enum av7110_video_output_mode { - NO_OUT = 0, //disable analog Output + NO_OUT = 0, /* disable analog output */ CVBS_RGB_OUT = 1, CVBS_YC_OUT = 2, YC_OUT = 3 }; -#define GPMQFull 0x0001 //Main Message Queue Full -#define GPMQOver 0x0002 //Main Message Queue Overflow -#define HPQFull 0x0004 //High Priority Msg Queue Full -#define HPQOver 0x0008 -#define OSDQFull 0x0010 //OSD Queue Full -#define OSDQOver 0x0020 - -#define SECTION_EIT 0x01 -#define SECTION_SINGLE 0x00 +/* firmware internal msg q status: */ +#define GPMQFull 0x0001 /* Main Message Queue Full */ +#define GPMQOver 0x0002 /* Main Message Queue Overflow */ +#define HPQFull 0x0004 /* High Priority Msg Queue Full */ +#define HPQOver 0x0008 +#define OSDQFull 0x0010 /* OSD Queue Full */ +#define OSDQOver 0x0020 + +/* hw section filter flags */ +#define SECTION_EIT 0x01 +#define SECTION_SINGLE 0x00 #define SECTION_CYCLE 0x02 #define SECTION_CONTINUOS 0x04 #define SECTION_MODE 0x06 -#define SECTION_IPMPE 0x0C // bis zu 4k groß -#define SECTION_HIGH_SPEED 0x1C // vergrößerter Puffer für High Speed Filter -#define DATA_PIPING_FLAG 0x20 // für Data Piping Filter +#define SECTION_IPMPE 0x0C /* size up to 4k */ +#define SECTION_HIGH_SPEED 0x1C /* larger buffer */ +#define DATA_PIPING_FLAG 0x20 /* for Data Piping Filter */ #define PBUFSIZE_NONE 0x0000 #define PBUFSIZE_1P 0x0100 @@ -107,8 +109,10 @@ enum av7110_video_output_mode #define PBUFSIZE_16K 0x0700 #define PBUFSIZE_32K 0x0800 + +/* firmware command codes */ enum av7110_osd_command { - WCreate, + WCreate, WDestroy, WMoveD, WMoveA, @@ -127,13 +131,13 @@ enum av7110_osd_command { BlitBmp, ReleaseBmp, SetWTrans, - SetWNoTrans, - Set_Palette + SetWNoTrans, + Set_Palette }; enum av7110_pid_command { MultiPID, - VideoPID, + VideoPID, AudioPID, InitFilt, FiltError, @@ -143,16 +147,16 @@ enum av7110_pid_command { DelPIDFilter, Scan, SetDescr, - SetIR, - FlushTSQueue + SetIR, + FlushTSQueue }; enum av7110_mpeg_command { - SelAudChannels + SelAudChannels }; enum av7110_audio_command { - AudioDAC, + AudioDAC, CabADAC, ON22K, OFF22K, @@ -163,7 +167,7 @@ enum av7110_audio_command { }; enum av7110_request_command { - AudioState, + AudioState, AudioBuffState, VideoState1, VideoState2, @@ -177,7 +181,7 @@ enum av7110_request_command { }; enum av7110_encoder_command { - SetVidMode, + SetVidMode, SetTestMode, LoadVidCode, SetMonitorType, @@ -186,7 +190,7 @@ enum av7110_encoder_command { }; enum av7110_rec_play_state { - __Record, + __Record, __Stop, __Play, __Pause, @@ -197,7 +201,7 @@ enum av7110_rec_play_state { }; enum av7110_command_type { - COMTYPE_NOCOM, + COMTYPE_NOCOM, COMTYPE_PIDFILTER, COMTYPE_MPEGDECODER, COMTYPE_OSD, @@ -209,82 +213,89 @@ enum av7110_command_type { COMTYPE_REC_PLAY, COMTYPE_COMMON_IF, COMTYPE_PID_FILTER, - COMTYPE_PES, - COMTYPE_TS, + COMTYPE_PES, + COMTYPE_TS, COMTYPE_VIDEO, COMTYPE_AUDIO, COMTYPE_CI_LL, }; -#define VID_NONE_PREF 0x00 /* No aspect ration processing preferred */ -#define VID_PAN_SCAN_PREF 0x01 /* Pan and Scan Display preferred */ -#define VID_VERT_COMP_PREF 0x02 /* Vertical compression display preferred */ -#define VID_VC_AND_PS_PREF 0x03 /* PanScan and vertical Compression if allowed */ -#define VID_CENTRE_CUT_PREF 0x05 /* PanScan with zero vector */ - -#define DATA_NONE 0x00 -#define DATA_FSECTION 0x01 -#define DATA_IPMPE 0x02 -#define DATA_MPEG_RECORD 0x03 -#define DATA_DEBUG_MESSAGE 0x04 -#define DATA_COMMON_INTERFACE 0x05 -#define DATA_MPEG_PLAY 0x06 -#define DATA_BMP_LOAD 0x07 -#define DATA_IRCOMMAND 0x08 -#define DATA_PIPING 0x09 -#define DATA_STREAMING 0x0a -#define DATA_CI_GET 0x0b -#define DATA_CI_PUT 0x0c -#define DATA_MPEG_VIDEO_EVENT 0x0d - -#define DATA_PES_RECORD 0x10 -#define DATA_PES_PLAY 0x11 -#define DATA_TS_RECORD 0x12 -#define DATA_TS_PLAY 0x13 - -#define CI_CMD_ERROR 0x00 -#define CI_CMD_ACK 0x01 -#define CI_CMD_SYSTEM_READY 0x02 -#define CI_CMD_KEYPRESS 0x03 -#define CI_CMD_ON_TUNED 0x04 +#define VID_NONE_PREF 0x00 /* No aspect ration processing preferred */ +#define VID_PAN_SCAN_PREF 0x01 /* Pan and Scan Display preferred */ +#define VID_VERT_COMP_PREF 0x02 /* Vertical compression display preferred */ +#define VID_VC_AND_PS_PREF 0x03 /* PanScan and vertical Compression if allowed */ +#define VID_CENTRE_CUT_PREF 0x05 /* PanScan with zero vector */ + +/* firmware data interface codes */ +#define DATA_NONE 0x00 +#define DATA_FSECTION 0x01 +#define DATA_IPMPE 0x02 +#define DATA_MPEG_RECORD 0x03 +#define DATA_DEBUG_MESSAGE 0x04 +#define DATA_COMMON_INTERFACE 0x05 +#define DATA_MPEG_PLAY 0x06 +#define DATA_BMP_LOAD 0x07 +#define DATA_IRCOMMAND 0x08 +#define DATA_PIPING 0x09 +#define DATA_STREAMING 0x0a +#define DATA_CI_GET 0x0b +#define DATA_CI_PUT 0x0c +#define DATA_MPEG_VIDEO_EVENT 0x0d + +#define DATA_PES_RECORD 0x10 +#define DATA_PES_PLAY 0x11 +#define DATA_TS_RECORD 0x12 +#define DATA_TS_PLAY 0x13 + +/* ancient CI command codes, only two are actually still used + * by the link level CI firmware */ +#define CI_CMD_ERROR 0x00 +#define CI_CMD_ACK 0x01 +#define CI_CMD_SYSTEM_READY 0x02 +#define CI_CMD_KEYPRESS 0x03 +#define CI_CMD_ON_TUNED 0x04 #define CI_CMD_ON_SWITCH_PROGRAM 0x05 -#define CI_CMD_SECTION_ARRIVED 0x06 -#define CI_CMD_SECTION_TIMEOUT 0x07 -#define CI_CMD_TIME 0x08 -#define CI_CMD_ENTER_MENU 0x09 -#define CI_CMD_FAST_PSI 0x0a -#define CI_CMD_GET_SLOT_INFO 0x0b - -#define CI_MSG_NONE 0x00 -#define CI_MSG_CI_INFO 0x01 -#define CI_MSG_MENU 0x02 -#define CI_MSG_LIST 0x03 -#define CI_MSG_TEXT 0x04 -#define CI_MSG_REQUEST_INPUT 0x05 -#define CI_MSG_INPUT_COMPLETE 0x06 -#define CI_MSG_LIST_MORE 0x07 -#define CI_MSG_MENU_MORE 0x08 -#define CI_MSG_CLOSE_MMI_IMM 0x09 -#define CI_MSG_SECTION_REQUEST 0x0a -#define CI_MSG_CLOSE_FILTER 0x0b -#define CI_PSI_COMPLETE 0x0c -#define CI_MODULE_READY 0x0d -#define CI_SWITCH_PRG_REPLY 0x0e -#define CI_MSG_TEXT_MORE 0x0f - -#define CI_MSG_CA_PMT 0xe0 -#define CI_MSG_ERROR 0xf0 - - - +#define CI_CMD_SECTION_ARRIVED 0x06 +#define CI_CMD_SECTION_TIMEOUT 0x07 +#define CI_CMD_TIME 0x08 +#define CI_CMD_ENTER_MENU 0x09 +#define CI_CMD_FAST_PSI 0x0a +#define CI_CMD_GET_SLOT_INFO 0x0b + +#define CI_MSG_NONE 0x00 +#define CI_MSG_CI_INFO 0x01 +#define CI_MSG_MENU 0x02 +#define CI_MSG_LIST 0x03 +#define CI_MSG_TEXT 0x04 +#define CI_MSG_REQUEST_INPUT 0x05 +#define CI_MSG_INPUT_COMPLETE 0x06 +#define CI_MSG_LIST_MORE 0x07 +#define CI_MSG_MENU_MORE 0x08 +#define CI_MSG_CLOSE_MMI_IMM 0x09 +#define CI_MSG_SECTION_REQUEST 0x0a +#define CI_MSG_CLOSE_FILTER 0x0b +#define CI_PSI_COMPLETE 0x0c +#define CI_MODULE_READY 0x0d +#define CI_SWITCH_PRG_REPLY 0x0e +#define CI_MSG_TEXT_MORE 0x0f + +#define CI_MSG_CA_PMT 0xe0 +#define CI_MSG_ERROR 0xf0 + + +/* base address of the dual ported RAM which serves as communication + * area between PCI bus and av7110, + * as seen by the DEBI bus of the saa7146 */ #define DPRAM_BASE 0x4000 +/* boot protocol area */ #define BOOT_STATE (DPRAM_BASE + 0x3F8) #define BOOT_SIZE (DPRAM_BASE + 0x3FA) #define BOOT_BASE (DPRAM_BASE + 0x3FC) #define BOOT_BLOCK (DPRAM_BASE + 0x400) #define BOOT_MAX_SIZE 0xc00 +/* firmware command protocol area */ #define IRQ_STATE (DPRAM_BASE + 0x0F4) #define IRQ_STATE_EXT (DPRAM_BASE + 0x0F6) #define MSGSTATE (DPRAM_BASE + 0x0F8) @@ -293,14 +304,10 @@ enum av7110_command_type { #define COM_BUFF (DPRAM_BASE + 0x100) #define COM_BUFF_SIZE 0x20 +/* various data buffers */ #define BUFF1_BASE (DPRAM_BASE + 0x120) #define BUFF1_SIZE 0xE0 -#define DATA_BUFF_BASE (DPRAM_BASE + 0x200) -#define DATA_BUFF_SIZE 0x1C00 - -/* new buffers */ - #define DATA_BUFF0_BASE (DPRAM_BASE + 0x200) #define DATA_BUFF0_SIZE 0x0800 @@ -316,21 +323,24 @@ enum av7110_command_type { #define Reserved (DPRAM_BASE + 0x1E00) #define Reserved_SIZE 0x1C0 + +/* firmware status area */ #define STATUS_BASE (DPRAM_BASE + 0x1FC0) -#define STATUS_SCR (STATUS_BASE + 0x00) -#define STATUS_MODES (STATUS_BASE + 0x04) -#define STATUS_LOOPS (STATUS_BASE + 0x08) +#define STATUS_SCR (STATUS_BASE + 0x00) +#define STATUS_MODES (STATUS_BASE + 0x04) +#define STATUS_LOOPS (STATUS_BASE + 0x08) #define STATUS_MPEG_WIDTH (STATUS_BASE + 0x0C) /* ((aspect_ratio & 0xf) << 12) | (height & 0xfff) */ #define STATUS_MPEG_HEIGHT_AR (STATUS_BASE + 0x0E) -#define RX_TYPE (DPRAM_BASE + 0x1FE8) -#define RX_LEN (DPRAM_BASE + 0x1FEA) -#define TX_TYPE (DPRAM_BASE + 0x1FEC) -#define TX_LEN (DPRAM_BASE + 0x1FEE) +/* firmware data protocol area */ +#define RX_TYPE (DPRAM_BASE + 0x1FE8) +#define RX_LEN (DPRAM_BASE + 0x1FEA) +#define TX_TYPE (DPRAM_BASE + 0x1FEC) +#define TX_LEN (DPRAM_BASE + 0x1FEE) -#define RX_BUFF (DPRAM_BASE + 0x1FF4) +#define RX_BUFF (DPRAM_BASE + 0x1FF4) #define TX_BUFF (DPRAM_BASE + 0x1FF6) #define HANDSHAKE_REG (DPRAM_BASE + 0x1FF8) @@ -339,21 +349,22 @@ enum av7110_command_type { #define IRQ_RX (DPRAM_BASE + 0x1FFC) #define IRQ_TX (DPRAM_BASE + 0x1FFE) +/* used by boot protocol to load firmware into av7110 DRAM */ #define DRAM_START_CODE 0x2e000404 #define DRAM_MAX_CODE_SIZE 0x00100000 +/* saa7146 gpio lines */ #define RESET_LINE 2 #define DEBI_DONE_LINE 1 #define ARM_IRQ_LINE 0 -#define DAC_CS 0x8000 -#define DAC_CDS 0x0000 - extern void reset_arm(struct av7110 *av7110); extern int bootarm(struct av7110 *av7110); extern void firmversion(struct av7110 *av7110); +#define FW_CI_LL_SUPPORT(arm_app) ((arm_app) & 0x80000000) +#define FW_VERSION(arm_app) ((arm_app) & 0x0000FFFF) extern int outcom(struct av7110 *av7110, int type, int com, int num, ...); extern int OutCommand(struct av7110 *av7110, u16* buf, int length); @@ -362,9 +373,6 @@ extern int SendCICommand(struct av7110 *av7110, u8 subcom, u8 *Params, u8 ParamL extern int CommandRequest(struct av7110 *av7110, u16 *Buff, int length, u16 *buf, int n); extern int RequestParameter(struct av7110 *av7110, u16 tag, u16* Buff, s16 length); -#define FW_CI_LL_SUPPORT(arm_app) ((arm_app) & 0x80000000) -#define FW_VERSION(arm_app) ((arm_app) & 0x0000FFFF) - /* DEBI (saa7146 data extension bus interface) access */ extern int av7110_debiwrite(struct av7110 *av7110, u32 config, @@ -377,61 +385,61 @@ extern u32 av7110_debiread(struct av7110 *av7110, u32 config, /* single word writes */ static inline void iwdebi(struct av7110 *av7110, u32 config, int addr, u32 val, int count) { - av7110_debiwrite(av7110, config, addr, val, count); + av7110_debiwrite(av7110, config, addr, val, count); } /* buffer writes */ static inline void mwdebi(struct av7110 *av7110, u32 config, int addr, char *val, int count) { memcpy(av7110->debi_virt, val, count); - av7110_debiwrite(av7110, config, addr, 0, count); + av7110_debiwrite(av7110, config, addr, 0, count); } static inline u32 irdebi(struct av7110 *av7110, u32 config, int addr, u32 val, int count) { - u32 res; + u32 res; - res=av7110_debiread(av7110, config, addr, count); - if (count<=4) - memcpy(av7110->debi_virt, (char *) &res, count); - return res; + res=av7110_debiread(av7110, config, addr, count); + if (count<=4) + memcpy(av7110->debi_virt, (char *) &res, count); + return res; } /* DEBI outside interrupts, only for count <= 4! */ static inline void wdebi(struct av7110 *av7110, u32 config, int addr, u32 val, int count) { - unsigned long flags; + unsigned long flags; - spin_lock_irqsave(&av7110->debilock, flags); - av7110_debiwrite(av7110, config, addr, val, count); - spin_unlock_irqrestore(&av7110->debilock, flags); + spin_lock_irqsave(&av7110->debilock, flags); + av7110_debiwrite(av7110, config, addr, val, count); + spin_unlock_irqrestore(&av7110->debilock, flags); } static inline u32 rdebi(struct av7110 *av7110, u32 config, int addr, u32 val, int count) { - unsigned long flags; - u32 res; + unsigned long flags; + u32 res; - spin_lock_irqsave(&av7110->debilock, flags); - res=av7110_debiread(av7110, config, addr, count); - spin_unlock_irqrestore(&av7110->debilock, flags); - return res; + spin_lock_irqsave(&av7110->debilock, flags); + res=av7110_debiread(av7110, config, addr, count); + spin_unlock_irqrestore(&av7110->debilock, flags); + return res; } /* handle mailbox registers of the dual ported RAM */ static inline void ARM_ResetMailBox(struct av7110 *av7110) { - unsigned long flags; + unsigned long flags; - spin_lock_irqsave(&av7110->debilock, flags); - av7110_debiread(av7110, DEBINOSWAP, IRQ_RX, 2); - av7110_debiwrite(av7110, DEBINOSWAP, IRQ_RX, 0, 2); - spin_unlock_irqrestore(&av7110->debilock, flags); + spin_lock_irqsave(&av7110->debilock, flags); + av7110_debiread(av7110, DEBINOSWAP, IRQ_RX, 2); + av7110_debiwrite(av7110, DEBINOSWAP, IRQ_RX, 0, 2); + spin_unlock_irqrestore(&av7110->debilock, flags); } static inline void ARM_ClearMailBox(struct av7110 *av7110) { - iwdebi(av7110, DEBINOSWAP, IRQ_RX, 0, 2); + iwdebi(av7110, DEBINOSWAP, IRQ_RX, 0, 2); } static inline void ARM_ClearIrq(struct av7110 *av7110) @@ -445,25 +453,25 @@ static inline void ARM_ClearIrq(struct av7110 *av7110) static inline int SendDAC(struct av7110 *av7110, u8 addr, u8 data) { - return outcom(av7110, COMTYPE_AUDIODAC, AudioDAC, 2, addr, data); + return outcom(av7110, COMTYPE_AUDIODAC, AudioDAC, 2, addr, data); } static inline void VidMode(struct av7110 *av7110, int mode) { - outcom(av7110, COMTYPE_ENCODER, SetVidMode, 1, mode); + outcom(av7110, COMTYPE_ENCODER, SetVidMode, 1, mode); } static int inline vidcom(struct av7110 *av7110, u32 com, u32 arg) { - return outcom(av7110, 0x80, 0x02, 4, - (com>>16), (com&0xffff), - (arg>>16), (arg&0xffff)); + return outcom(av7110, 0x80, 0x02, 4, + (com>>16), (com&0xffff), + (arg>>16), (arg&0xffff)); } static int inline audcom(struct av7110 *av7110, u32 com) { return outcom(av7110, 0x80, 0x03, 4, - (com>>16), (com&0xffff)); + (com>>16), (com&0xffff)); } static inline void Set22K(struct av7110 *av7110, int state) |