Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * av7110_hw.c: av7110 low level hardware access and firmware interface |
| 3 | * |
| 4 | * Copyright (C) 1999-2002 Ralph Metzler |
| 5 | * & Marcus Metzler for convergence integrated media GmbH |
| 6 | * |
| 7 | * originally based on code by: |
| 8 | * Copyright (C) 1998,1999 Christian Theiss <mistert@rz.fh-augsburg.de> |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or |
| 11 | * modify it under the terms of the GNU General Public License |
| 12 | * as published by the Free Software Foundation; either version 2 |
| 13 | * of the License, or (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program; if not, write to the Free Software |
| 22 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 23 | * Or, point your browser to http://www.gnu.org/copyleft/gpl.html |
| 24 | * |
Justin P. Mattock | 631dd1a | 2010-10-18 11:03:14 +0200 | [diff] [blame] | 25 | * the project's page is at http://www.linuxtv.org/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | */ |
| 27 | |
| 28 | /* for debugging ARM communication: */ |
| 29 | //#define COM_DEBUG |
| 30 | |
| 31 | #include <stdarg.h> |
| 32 | #include <linux/types.h> |
| 33 | #include <linux/kernel.h> |
| 34 | #include <linux/string.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | #include <linux/delay.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | #include <linux/fs.h> |
| 37 | |
| 38 | #include "av7110.h" |
| 39 | #include "av7110_hw.h" |
| 40 | |
Johannes Stezenbach | ce7d3c1 | 2005-09-09 13:03:10 -0700 | [diff] [blame] | 41 | #define _NOHANDSHAKE |
| 42 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | /**************************************************************************** |
| 44 | * DEBI functions |
| 45 | ****************************************************************************/ |
| 46 | |
| 47 | /* This DEBI code is based on the Stradis driver |
| 48 | by Nathan Laredo <laredo@gnu.org> */ |
| 49 | |
| 50 | int av7110_debiwrite(struct av7110 *av7110, u32 config, |
| 51 | int addr, u32 val, int count) |
| 52 | { |
| 53 | struct saa7146_dev *dev = av7110->dev; |
| 54 | |
| 55 | if (count <= 0 || count > 32764) { |
Harvey Harrison | 3ca7fc8 | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 56 | printk("%s: invalid count %d\n", __func__, count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | return -1; |
| 58 | } |
| 59 | if (saa7146_wait_for_debi_done(av7110->dev, 0) < 0) { |
Harvey Harrison | 3ca7fc8 | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 60 | printk("%s: wait_for_debi_done failed\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | return -1; |
| 62 | } |
| 63 | saa7146_write(dev, DEBI_CONFIG, config); |
| 64 | if (count <= 4) /* immediate transfer */ |
| 65 | saa7146_write(dev, DEBI_AD, val); |
| 66 | else /* block transfer */ |
| 67 | saa7146_write(dev, DEBI_AD, av7110->debi_bus); |
| 68 | saa7146_write(dev, DEBI_COMMAND, (count << 17) | (addr & 0xffff)); |
| 69 | saa7146_write(dev, MC2, (2 << 16) | 2); |
| 70 | return 0; |
| 71 | } |
| 72 | |
| 73 | u32 av7110_debiread(struct av7110 *av7110, u32 config, int addr, int count) |
| 74 | { |
| 75 | struct saa7146_dev *dev = av7110->dev; |
| 76 | u32 result = 0; |
| 77 | |
| 78 | if (count > 32764 || count <= 0) { |
Harvey Harrison | 3ca7fc8 | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 79 | printk("%s: invalid count %d\n", __func__, count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | return 0; |
| 81 | } |
| 82 | if (saa7146_wait_for_debi_done(av7110->dev, 0) < 0) { |
Harvey Harrison | 3ca7fc8 | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 83 | printk("%s: wait_for_debi_done #1 failed\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | return 0; |
| 85 | } |
| 86 | saa7146_write(dev, DEBI_AD, av7110->debi_bus); |
| 87 | saa7146_write(dev, DEBI_COMMAND, (count << 17) | 0x10000 | (addr & 0xffff)); |
| 88 | |
| 89 | saa7146_write(dev, DEBI_CONFIG, config); |
| 90 | saa7146_write(dev, MC2, (2 << 16) | 2); |
| 91 | if (count > 4) |
| 92 | return count; |
| 93 | if (saa7146_wait_for_debi_done(av7110->dev, 0) < 0) { |
Harvey Harrison | 3ca7fc8 | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 94 | printk("%s: wait_for_debi_done #2 failed\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | return 0; |
| 96 | } |
| 97 | |
| 98 | result = saa7146_read(dev, DEBI_AD); |
| 99 | result &= (0xffffffffUL >> ((4 - count) * 8)); |
| 100 | return result; |
| 101 | } |
| 102 | |
| 103 | |
| 104 | |
| 105 | /* av7110 ARM core boot stuff */ |
Johannes Stezenbach | d91b730 | 2005-05-16 21:54:38 -0700 | [diff] [blame] | 106 | #if 0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | void av7110_reset_arm(struct av7110 *av7110) |
| 108 | { |
| 109 | saa7146_setgpio(av7110->dev, RESET_LINE, SAA7146_GPIO_OUTLO); |
| 110 | |
| 111 | /* Disable DEBI and GPIO irq */ |
| 112 | SAA7146_IER_DISABLE(av7110->dev, MASK_19 | MASK_03); |
| 113 | SAA7146_ISR_CLEAR(av7110->dev, MASK_19 | MASK_03); |
| 114 | |
| 115 | saa7146_setgpio(av7110->dev, RESET_LINE, SAA7146_GPIO_OUTHI); |
| 116 | msleep(30); /* the firmware needs some time to initialize */ |
| 117 | |
| 118 | ARM_ResetMailBox(av7110); |
| 119 | |
| 120 | SAA7146_ISR_CLEAR(av7110->dev, MASK_19 | MASK_03); |
| 121 | SAA7146_IER_ENABLE(av7110->dev, MASK_03); |
| 122 | |
| 123 | av7110->arm_ready = 1; |
| 124 | dprintk(1, "reset ARM\n"); |
| 125 | } |
Johannes Stezenbach | d91b730 | 2005-05-16 21:54:38 -0700 | [diff] [blame] | 126 | #endif /* 0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | |
| 128 | static int waitdebi(struct av7110 *av7110, int adr, int state) |
| 129 | { |
| 130 | int k; |
| 131 | |
| 132 | dprintk(4, "%p\n", av7110); |
| 133 | |
| 134 | for (k = 0; k < 100; k++) { |
| 135 | if (irdebi(av7110, DEBINOSWAP, adr, 0, 2) == state) |
| 136 | return 0; |
| 137 | udelay(5); |
| 138 | } |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 139 | return -ETIMEDOUT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | static int load_dram(struct av7110 *av7110, u32 *data, int len) |
| 143 | { |
| 144 | int i; |
| 145 | int blocks, rest; |
Mauro Carvalho Chehab | fabd238 | 2006-01-15 08:12:14 -0200 | [diff] [blame] | 146 | u32 base, bootblock = AV7110_BOOT_BLOCK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | |
| 148 | dprintk(4, "%p\n", av7110); |
| 149 | |
Mauro Carvalho Chehab | fabd238 | 2006-01-15 08:12:14 -0200 | [diff] [blame] | 150 | blocks = len / AV7110_BOOT_MAX_SIZE; |
| 151 | rest = len % AV7110_BOOT_MAX_SIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | base = DRAM_START_CODE; |
| 153 | |
| 154 | for (i = 0; i < blocks; i++) { |
Mauro Carvalho Chehab | fabd238 | 2006-01-15 08:12:14 -0200 | [diff] [blame] | 155 | if (waitdebi(av7110, AV7110_BOOT_STATE, BOOTSTATE_BUFFER_EMPTY) < 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | printk(KERN_ERR "dvb-ttpci: load_dram(): timeout at block %d\n", i); |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 157 | return -ETIMEDOUT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | } |
| 159 | dprintk(4, "writing DRAM block %d\n", i); |
| 160 | mwdebi(av7110, DEBISWAB, bootblock, |
Oliver Endriss | 804b445 | 2007-07-12 20:37:50 -0300 | [diff] [blame] | 161 | ((u8 *)data) + i * AV7110_BOOT_MAX_SIZE, AV7110_BOOT_MAX_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | bootblock ^= 0x1400; |
Mauro Carvalho Chehab | fabd238 | 2006-01-15 08:12:14 -0200 | [diff] [blame] | 163 | iwdebi(av7110, DEBISWAB, AV7110_BOOT_BASE, swab32(base), 4); |
| 164 | iwdebi(av7110, DEBINOSWAP, AV7110_BOOT_SIZE, AV7110_BOOT_MAX_SIZE, 2); |
| 165 | iwdebi(av7110, DEBINOSWAP, AV7110_BOOT_STATE, BOOTSTATE_BUFFER_FULL, 2); |
| 166 | base += AV7110_BOOT_MAX_SIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | if (rest > 0) { |
Mauro Carvalho Chehab | fabd238 | 2006-01-15 08:12:14 -0200 | [diff] [blame] | 170 | if (waitdebi(av7110, AV7110_BOOT_STATE, BOOTSTATE_BUFFER_EMPTY) < 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | printk(KERN_ERR "dvb-ttpci: load_dram(): timeout at last block\n"); |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 172 | return -ETIMEDOUT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | } |
| 174 | if (rest > 4) |
| 175 | mwdebi(av7110, DEBISWAB, bootblock, |
Oliver Endriss | 804b445 | 2007-07-12 20:37:50 -0300 | [diff] [blame] | 176 | ((u8 *)data) + i * AV7110_BOOT_MAX_SIZE, rest); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | else |
| 178 | mwdebi(av7110, DEBISWAB, bootblock, |
Oliver Endriss | 804b445 | 2007-07-12 20:37:50 -0300 | [diff] [blame] | 179 | ((u8 *)data) + i * AV7110_BOOT_MAX_SIZE - 4, rest + 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | |
Mauro Carvalho Chehab | fabd238 | 2006-01-15 08:12:14 -0200 | [diff] [blame] | 181 | iwdebi(av7110, DEBISWAB, AV7110_BOOT_BASE, swab32(base), 4); |
| 182 | iwdebi(av7110, DEBINOSWAP, AV7110_BOOT_SIZE, rest, 2); |
| 183 | iwdebi(av7110, DEBINOSWAP, AV7110_BOOT_STATE, BOOTSTATE_BUFFER_FULL, 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | } |
Mauro Carvalho Chehab | fabd238 | 2006-01-15 08:12:14 -0200 | [diff] [blame] | 185 | if (waitdebi(av7110, AV7110_BOOT_STATE, BOOTSTATE_BUFFER_EMPTY) < 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | printk(KERN_ERR "dvb-ttpci: load_dram(): timeout after last block\n"); |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 187 | return -ETIMEDOUT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | } |
Mauro Carvalho Chehab | fabd238 | 2006-01-15 08:12:14 -0200 | [diff] [blame] | 189 | iwdebi(av7110, DEBINOSWAP, AV7110_BOOT_SIZE, 0, 2); |
| 190 | iwdebi(av7110, DEBINOSWAP, AV7110_BOOT_STATE, BOOTSTATE_BUFFER_FULL, 2); |
| 191 | if (waitdebi(av7110, AV7110_BOOT_STATE, BOOTSTATE_AV7110_BOOT_COMPLETE) < 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | printk(KERN_ERR "dvb-ttpci: load_dram(): final handshake timeout\n"); |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 193 | return -ETIMEDOUT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | } |
| 195 | return 0; |
| 196 | } |
| 197 | |
| 198 | |
| 199 | /* we cannot write av7110 DRAM directly, so load a bootloader into |
| 200 | * the DPRAM which implements a simple boot protocol */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | int av7110_bootarm(struct av7110 *av7110) |
| 202 | { |
Jaswinder Singh | 9137f05 | 2009-04-06 14:34:12 -0700 | [diff] [blame] | 203 | const struct firmware *fw; |
| 204 | const char *fw_name = "av7110/bootcode.bin"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | struct saa7146_dev *dev = av7110->dev; |
| 206 | u32 ret; |
| 207 | int i; |
| 208 | |
| 209 | dprintk(4, "%p\n", av7110); |
| 210 | |
Oliver Endriss | 66190a2 | 2006-01-09 15:32:42 -0200 | [diff] [blame] | 211 | av7110->arm_ready = 0; |
| 212 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | saa7146_setgpio(dev, RESET_LINE, SAA7146_GPIO_OUTLO); |
| 214 | |
| 215 | /* Disable DEBI and GPIO irq */ |
| 216 | SAA7146_IER_DISABLE(av7110->dev, MASK_03 | MASK_19); |
| 217 | SAA7146_ISR_CLEAR(av7110->dev, MASK_19 | MASK_03); |
| 218 | |
| 219 | /* enable DEBI */ |
| 220 | saa7146_write(av7110->dev, MC1, 0x08800880); |
| 221 | saa7146_write(av7110->dev, DD1_STREAM_B, 0x00000000); |
| 222 | saa7146_write(av7110->dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26)); |
| 223 | |
| 224 | /* test DEBI */ |
| 225 | iwdebi(av7110, DEBISWAP, DPRAM_BASE, 0x76543210, 4); |
Marco Schluessler | 9f3319b | 2006-02-24 18:53:00 -0300 | [diff] [blame] | 226 | /* FIXME: Why does Nexus CA require 2x iwdebi for first init? */ |
| 227 | iwdebi(av7110, DEBISWAP, DPRAM_BASE, 0x76543210, 4); |
| 228 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 229 | if ((ret=irdebi(av7110, DEBINOSWAP, DPRAM_BASE, 0, 4)) != 0x10325476) { |
| 230 | printk(KERN_ERR "dvb-ttpci: debi test in av7110_bootarm() failed: " |
| 231 | "%08x != %08x (check your BIOS 'Plug&Play OS' settings)\n", |
| 232 | ret, 0x10325476); |
| 233 | return -1; |
| 234 | } |
| 235 | for (i = 0; i < 8192; i += 4) |
| 236 | iwdebi(av7110, DEBISWAP, DPRAM_BASE + i, 0x00, 4); |
| 237 | dprintk(2, "debi test OK\n"); |
| 238 | |
| 239 | /* boot */ |
| 240 | dprintk(1, "load boot code\n"); |
| 241 | saa7146_setgpio(dev, ARM_IRQ_LINE, SAA7146_GPIO_IRQLO); |
| 242 | //saa7146_setgpio(dev, DEBI_DONE_LINE, SAA7146_GPIO_INPUT); |
| 243 | //saa7146_setgpio(dev, 3, SAA7146_GPIO_INPUT); |
| 244 | |
Jaswinder Singh | 9137f05 | 2009-04-06 14:34:12 -0700 | [diff] [blame] | 245 | ret = request_firmware(&fw, fw_name, &dev->pci->dev); |
| 246 | if (ret) { |
| 247 | printk(KERN_ERR "dvb-ttpci: Failed to load firmware \"%s\"\n", |
| 248 | fw_name); |
| 249 | return ret; |
| 250 | } |
| 251 | |
| 252 | mwdebi(av7110, DEBISWAB, DPRAM_BASE, fw->data, fw->size); |
| 253 | release_firmware(fw); |
Mauro Carvalho Chehab | fabd238 | 2006-01-15 08:12:14 -0200 | [diff] [blame] | 254 | iwdebi(av7110, DEBINOSWAP, AV7110_BOOT_STATE, BOOTSTATE_BUFFER_FULL, 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | |
| 256 | if (saa7146_wait_for_debi_done(av7110->dev, 1)) { |
| 257 | printk(KERN_ERR "dvb-ttpci: av7110_bootarm(): " |
| 258 | "saa7146_wait_for_debi_done() timed out\n"); |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 259 | return -ETIMEDOUT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | } |
| 261 | saa7146_setgpio(dev, RESET_LINE, SAA7146_GPIO_OUTHI); |
| 262 | mdelay(1); |
| 263 | |
| 264 | dprintk(1, "load dram code\n"); |
| 265 | if (load_dram(av7110, (u32 *)av7110->bin_root, av7110->size_root) < 0) { |
| 266 | printk(KERN_ERR "dvb-ttpci: av7110_bootarm(): " |
| 267 | "load_dram() failed\n"); |
| 268 | return -1; |
| 269 | } |
| 270 | |
| 271 | saa7146_setgpio(dev, RESET_LINE, SAA7146_GPIO_OUTLO); |
| 272 | mdelay(1); |
| 273 | |
| 274 | dprintk(1, "load dpram code\n"); |
| 275 | mwdebi(av7110, DEBISWAB, DPRAM_BASE, av7110->bin_dpram, av7110->size_dpram); |
| 276 | |
| 277 | if (saa7146_wait_for_debi_done(av7110->dev, 1)) { |
| 278 | printk(KERN_ERR "dvb-ttpci: av7110_bootarm(): " |
| 279 | "saa7146_wait_for_debi_done() timed out after loading DRAM\n"); |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 280 | return -ETIMEDOUT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | } |
| 282 | saa7146_setgpio(dev, RESET_LINE, SAA7146_GPIO_OUTHI); |
| 283 | msleep(30); /* the firmware needs some time to initialize */ |
| 284 | |
| 285 | //ARM_ClearIrq(av7110); |
| 286 | ARM_ResetMailBox(av7110); |
| 287 | SAA7146_ISR_CLEAR(av7110->dev, MASK_19 | MASK_03); |
| 288 | SAA7146_IER_ENABLE(av7110->dev, MASK_03); |
| 289 | |
| 290 | av7110->arm_errors = 0; |
| 291 | av7110->arm_ready = 1; |
| 292 | return 0; |
| 293 | } |
Jaswinder Singh | 9137f05 | 2009-04-06 14:34:12 -0700 | [diff] [blame] | 294 | MODULE_FIRMWARE("av7110/bootcode.bin"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | |
| 296 | /**************************************************************************** |
| 297 | * DEBI command polling |
| 298 | ****************************************************************************/ |
| 299 | |
| 300 | int av7110_wait_msgstate(struct av7110 *av7110, u16 flags) |
| 301 | { |
| 302 | unsigned long start; |
| 303 | u32 stat; |
Oliver Endriss | 25de192 | 2005-07-07 17:58:28 -0700 | [diff] [blame] | 304 | int err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | |
| 306 | if (FW_VERSION(av7110->arm_app) <= 0x261c) { |
| 307 | /* not supported by old firmware */ |
| 308 | msleep(50); |
| 309 | return 0; |
| 310 | } |
| 311 | |
| 312 | /* new firmware */ |
| 313 | start = jiffies; |
| 314 | for (;;) { |
Oliver Endriss | 25de192 | 2005-07-07 17:58:28 -0700 | [diff] [blame] | 315 | err = time_after(jiffies, start + ARM_WAIT_FREE); |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 316 | if (mutex_lock_interruptible(&av7110->dcomlock)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | return -ERESTARTSYS; |
| 318 | stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2); |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 319 | mutex_unlock(&av7110->dcomlock); |
Oliver Endriss | 25de192 | 2005-07-07 17:58:28 -0700 | [diff] [blame] | 320 | if ((stat & flags) == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | break; |
Oliver Endriss | 25de192 | 2005-07-07 17:58:28 -0700 | [diff] [blame] | 322 | if (err) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | printk(KERN_ERR "%s: timeout waiting for MSGSTATE %04x\n", |
Harvey Harrison | 3ca7fc8 | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 324 | __func__, stat & flags); |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 325 | return -ETIMEDOUT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | } |
| 327 | msleep(1); |
| 328 | } |
| 329 | return 0; |
| 330 | } |
| 331 | |
Johannes Stezenbach | d91b730 | 2005-05-16 21:54:38 -0700 | [diff] [blame] | 332 | static int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | { |
| 334 | int i; |
| 335 | unsigned long start; |
| 336 | char *type = NULL; |
| 337 | u16 flags[2] = {0, 0}; |
| 338 | u32 stat; |
Oliver Endriss | 25de192 | 2005-07-07 17:58:28 -0700 | [diff] [blame] | 339 | int err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | |
| 341 | // dprintk(4, "%p\n", av7110); |
| 342 | |
| 343 | if (!av7110->arm_ready) { |
| 344 | dprintk(1, "arm not ready.\n"); |
| 345 | return -ENXIO; |
| 346 | } |
| 347 | |
| 348 | start = jiffies; |
Oliver Endriss | 25de192 | 2005-07-07 17:58:28 -0700 | [diff] [blame] | 349 | while (1) { |
| 350 | err = time_after(jiffies, start + ARM_WAIT_FREE); |
| 351 | if (rdebi(av7110, DEBINOSWAP, COMMAND, 0, 2) == 0) |
| 352 | break; |
| 353 | if (err) { |
Harvey Harrison | 3ca7fc8 | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 354 | printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for COMMAND idle\n", __func__); |
Oliver Endriss | 66190a2 | 2006-01-09 15:32:42 -0200 | [diff] [blame] | 355 | av7110->arm_errors++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | return -ETIMEDOUT; |
| 357 | } |
Johannes Stezenbach | 7d87bc3 | 2005-07-07 17:57:56 -0700 | [diff] [blame] | 358 | msleep(1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | } |
| 360 | |
Oliver Endriss | 9a7b102 | 2005-09-09 13:03:11 -0700 | [diff] [blame] | 361 | if (FW_VERSION(av7110->arm_app) <= 0x261f) |
| 362 | wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0xffff, 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | |
| 364 | #ifndef _NOHANDSHAKE |
| 365 | start = jiffies; |
Oliver Endriss | 25de192 | 2005-07-07 17:58:28 -0700 | [diff] [blame] | 366 | while (1) { |
| 367 | err = time_after(jiffies, start + ARM_WAIT_SHAKE); |
| 368 | if (rdebi(av7110, DEBINOSWAP, HANDSHAKE_REG, 0, 2) == 0) |
| 369 | break; |
| 370 | if (err) { |
Harvey Harrison | 3ca7fc8 | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 371 | printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for HANDSHAKE_REG\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 372 | return -ETIMEDOUT; |
| 373 | } |
Johannes Stezenbach | 7d87bc3 | 2005-07-07 17:57:56 -0700 | [diff] [blame] | 374 | msleep(1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | } |
| 376 | #endif |
| 377 | |
| 378 | switch ((buf[0] >> 8) & 0xff) { |
| 379 | case COMTYPE_PIDFILTER: |
| 380 | case COMTYPE_ENCODER: |
| 381 | case COMTYPE_REC_PLAY: |
| 382 | case COMTYPE_MPEGDECODER: |
| 383 | type = "MSG"; |
| 384 | flags[0] = GPMQOver; |
| 385 | flags[1] = GPMQFull; |
| 386 | break; |
| 387 | case COMTYPE_OSD: |
| 388 | type = "OSD"; |
| 389 | flags[0] = OSDQOver; |
| 390 | flags[1] = OSDQFull; |
| 391 | break; |
| 392 | case COMTYPE_MISC: |
| 393 | if (FW_VERSION(av7110->arm_app) >= 0x261d) { |
| 394 | type = "MSG"; |
| 395 | flags[0] = GPMQOver; |
| 396 | flags[1] = GPMQBusy; |
| 397 | } |
| 398 | break; |
| 399 | default: |
| 400 | break; |
| 401 | } |
| 402 | |
| 403 | if (type != NULL) { |
| 404 | /* non-immediate COMMAND type */ |
| 405 | start = jiffies; |
| 406 | for (;;) { |
Oliver Endriss | 25de192 | 2005-07-07 17:58:28 -0700 | [diff] [blame] | 407 | err = time_after(jiffies, start + ARM_WAIT_FREE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 408 | stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2); |
| 409 | if (stat & flags[0]) { |
| 410 | printk(KERN_ERR "%s: %s QUEUE overflow\n", |
Harvey Harrison | 3ca7fc8 | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 411 | __func__, type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 412 | return -1; |
| 413 | } |
| 414 | if ((stat & flags[1]) == 0) |
| 415 | break; |
Oliver Endriss | 25de192 | 2005-07-07 17:58:28 -0700 | [diff] [blame] | 416 | if (err) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 417 | printk(KERN_ERR "%s: timeout waiting on busy %s QUEUE\n", |
Harvey Harrison | 3ca7fc8 | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 418 | __func__, type); |
Oliver Endriss | edabaff | 2008-06-19 23:04:27 -0300 | [diff] [blame] | 419 | av7110->arm_errors++; |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 420 | return -ETIMEDOUT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | } |
| 422 | msleep(1); |
| 423 | } |
| 424 | } |
| 425 | |
| 426 | for (i = 2; i < length; i++) |
| 427 | wdebi(av7110, DEBINOSWAP, COMMAND + 2 * i, (u32) buf[i], 2); |
| 428 | |
| 429 | if (length) |
| 430 | wdebi(av7110, DEBINOSWAP, COMMAND + 2, (u32) buf[1], 2); |
| 431 | else |
| 432 | wdebi(av7110, DEBINOSWAP, COMMAND + 2, 0, 2); |
| 433 | |
| 434 | wdebi(av7110, DEBINOSWAP, COMMAND, (u32) buf[0], 2); |
| 435 | |
Oliver Endriss | 9a7b102 | 2005-09-09 13:03:11 -0700 | [diff] [blame] | 436 | if (FW_VERSION(av7110->arm_app) <= 0x261f) |
| 437 | wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0x0000, 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 438 | |
| 439 | #ifdef COM_DEBUG |
| 440 | start = jiffies; |
Oliver Endriss | 25de192 | 2005-07-07 17:58:28 -0700 | [diff] [blame] | 441 | while (1) { |
| 442 | err = time_after(jiffies, start + ARM_WAIT_FREE); |
| 443 | if (rdebi(av7110, DEBINOSWAP, COMMAND, 0, 2) == 0) |
| 444 | break; |
| 445 | if (err) { |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 446 | printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for COMMAND %d to complete\n", |
Harvey Harrison | 3ca7fc8 | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 447 | __func__, (buf[0] >> 8) & 0xff); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | return -ETIMEDOUT; |
| 449 | } |
Johannes Stezenbach | 7d87bc3 | 2005-07-07 17:57:56 -0700 | [diff] [blame] | 450 | msleep(1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | } |
| 452 | |
| 453 | stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2); |
| 454 | if (stat & GPMQOver) { |
Harvey Harrison | 3ca7fc8 | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 455 | printk(KERN_ERR "dvb-ttpci: %s(): GPMQOver\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 456 | return -ENOSPC; |
| 457 | } |
| 458 | else if (stat & OSDQOver) { |
Harvey Harrison | 3ca7fc8 | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 459 | printk(KERN_ERR "dvb-ttpci: %s(): OSDQOver\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 460 | return -ENOSPC; |
| 461 | } |
| 462 | #endif |
| 463 | |
| 464 | return 0; |
| 465 | } |
| 466 | |
Johannes Stezenbach | d91b730 | 2005-05-16 21:54:38 -0700 | [diff] [blame] | 467 | static int av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 468 | { |
| 469 | int ret; |
| 470 | |
| 471 | // dprintk(4, "%p\n", av7110); |
| 472 | |
| 473 | if (!av7110->arm_ready) { |
| 474 | dprintk(1, "arm not ready.\n"); |
| 475 | return -1; |
| 476 | } |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 477 | if (mutex_lock_interruptible(&av7110->dcomlock)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 478 | return -ERESTARTSYS; |
| 479 | |
| 480 | ret = __av7110_send_fw_cmd(av7110, buf, length); |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 481 | mutex_unlock(&av7110->dcomlock); |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 482 | if (ret && ret!=-ERESTARTSYS) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 | printk(KERN_ERR "dvb-ttpci: %s(): av7110_send_fw_cmd error %d\n", |
Harvey Harrison | 3ca7fc8 | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 484 | __func__, ret); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | return ret; |
| 486 | } |
| 487 | |
| 488 | int av7110_fw_cmd(struct av7110 *av7110, int type, int com, int num, ...) |
| 489 | { |
| 490 | va_list args; |
| 491 | u16 buf[num + 2]; |
| 492 | int i, ret; |
| 493 | |
| 494 | // dprintk(4, "%p\n", av7110); |
| 495 | |
| 496 | buf[0] = ((type << 8) | com); |
| 497 | buf[1] = num; |
| 498 | |
| 499 | if (num) { |
| 500 | va_start(args, num); |
| 501 | for (i = 0; i < num; i++) |
| 502 | buf[i + 2] = va_arg(args, u32); |
| 503 | va_end(args); |
| 504 | } |
| 505 | |
| 506 | ret = av7110_send_fw_cmd(av7110, buf, num + 2); |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 507 | if (ret && ret != -ERESTARTSYS) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 508 | printk(KERN_ERR "dvb-ttpci: av7110_fw_cmd error %d\n", ret); |
| 509 | return ret; |
| 510 | } |
| 511 | |
Johannes Stezenbach | d91b730 | 2005-05-16 21:54:38 -0700 | [diff] [blame] | 512 | #if 0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 513 | int av7110_send_ci_cmd(struct av7110 *av7110, u8 subcom, u8 *buf, u8 len) |
| 514 | { |
| 515 | int i, ret; |
| 516 | u16 cmd[18] = { ((COMTYPE_COMMON_IF << 8) + subcom), |
| 517 | 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; |
| 518 | |
| 519 | dprintk(4, "%p\n", av7110); |
| 520 | |
| 521 | for(i = 0; i < len && i < 32; i++) |
| 522 | { |
| 523 | if(i % 2 == 0) |
| 524 | cmd[(i / 2) + 2] = (u16)(buf[i]) << 8; |
| 525 | else |
| 526 | cmd[(i / 2) + 2] |= buf[i]; |
| 527 | } |
| 528 | |
| 529 | ret = av7110_send_fw_cmd(av7110, cmd, 18); |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 530 | if (ret && ret != -ERESTARTSYS) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 531 | printk(KERN_ERR "dvb-ttpci: av7110_send_ci_cmd error %d\n", ret); |
| 532 | return ret; |
| 533 | } |
Johannes Stezenbach | d91b730 | 2005-05-16 21:54:38 -0700 | [diff] [blame] | 534 | #endif /* 0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 535 | |
| 536 | int av7110_fw_request(struct av7110 *av7110, u16 *request_buf, |
| 537 | int request_buf_len, u16 *reply_buf, int reply_buf_len) |
| 538 | { |
| 539 | int err; |
| 540 | s16 i; |
| 541 | unsigned long start; |
| 542 | #ifdef COM_DEBUG |
| 543 | u32 stat; |
| 544 | #endif |
| 545 | |
| 546 | dprintk(4, "%p\n", av7110); |
| 547 | |
| 548 | if (!av7110->arm_ready) { |
| 549 | dprintk(1, "arm not ready.\n"); |
| 550 | return -1; |
| 551 | } |
| 552 | |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 553 | if (mutex_lock_interruptible(&av7110->dcomlock)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 554 | return -ERESTARTSYS; |
| 555 | |
| 556 | if ((err = __av7110_send_fw_cmd(av7110, request_buf, request_buf_len)) < 0) { |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 557 | mutex_unlock(&av7110->dcomlock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 558 | printk(KERN_ERR "dvb-ttpci: av7110_fw_request error %d\n", err); |
| 559 | return err; |
| 560 | } |
| 561 | |
| 562 | start = jiffies; |
Oliver Endriss | 25de192 | 2005-07-07 17:58:28 -0700 | [diff] [blame] | 563 | while (1) { |
| 564 | err = time_after(jiffies, start + ARM_WAIT_FREE); |
| 565 | if (rdebi(av7110, DEBINOSWAP, COMMAND, 0, 2) == 0) |
| 566 | break; |
| 567 | if (err) { |
Harvey Harrison | 3ca7fc8 | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 568 | printk(KERN_ERR "%s: timeout waiting for COMMAND to complete\n", __func__); |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 569 | mutex_unlock(&av7110->dcomlock); |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 570 | return -ETIMEDOUT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | } |
Johannes Stezenbach | 7d87bc3 | 2005-07-07 17:57:56 -0700 | [diff] [blame] | 572 | #ifdef _NOHANDSHAKE |
| 573 | msleep(1); |
| 574 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 575 | } |
| 576 | |
| 577 | #ifndef _NOHANDSHAKE |
| 578 | start = jiffies; |
Oliver Endriss | 25de192 | 2005-07-07 17:58:28 -0700 | [diff] [blame] | 579 | while (1) { |
| 580 | err = time_after(jiffies, start + ARM_WAIT_SHAKE); |
| 581 | if (rdebi(av7110, DEBINOSWAP, HANDSHAKE_REG, 0, 2) == 0) |
| 582 | break; |
| 583 | if (err) { |
Harvey Harrison | 3ca7fc8 | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 584 | printk(KERN_ERR "%s: timeout waiting for HANDSHAKE_REG\n", __func__); |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 585 | mutex_unlock(&av7110->dcomlock); |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 586 | return -ETIMEDOUT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 587 | } |
Johannes Stezenbach | 7d87bc3 | 2005-07-07 17:57:56 -0700 | [diff] [blame] | 588 | msleep(1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 589 | } |
| 590 | #endif |
| 591 | |
| 592 | #ifdef COM_DEBUG |
| 593 | stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2); |
| 594 | if (stat & GPMQOver) { |
Harvey Harrison | 3ca7fc8 | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 595 | printk(KERN_ERR "%s: GPMQOver\n", __func__); |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 596 | mutex_unlock(&av7110->dcomlock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | return -1; |
| 598 | } |
| 599 | else if (stat & OSDQOver) { |
Harvey Harrison | 3ca7fc8 | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 600 | printk(KERN_ERR "%s: OSDQOver\n", __func__); |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 601 | mutex_unlock(&av7110->dcomlock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 602 | return -1; |
| 603 | } |
| 604 | #endif |
| 605 | |
| 606 | for (i = 0; i < reply_buf_len; i++) |
| 607 | reply_buf[i] = rdebi(av7110, DEBINOSWAP, COM_BUFF + 2 * i, 0, 2); |
| 608 | |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 609 | mutex_unlock(&av7110->dcomlock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | return 0; |
| 611 | } |
| 612 | |
Johannes Stezenbach | d91b730 | 2005-05-16 21:54:38 -0700 | [diff] [blame] | 613 | static int av7110_fw_query(struct av7110 *av7110, u16 tag, u16* buf, s16 length) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 614 | { |
| 615 | int ret; |
| 616 | ret = av7110_fw_request(av7110, &tag, 0, buf, length); |
| 617 | if (ret) |
| 618 | printk(KERN_ERR "dvb-ttpci: av7110_fw_query error %d\n", ret); |
| 619 | return ret; |
| 620 | } |
| 621 | |
| 622 | |
| 623 | /**************************************************************************** |
| 624 | * Firmware commands |
| 625 | ****************************************************************************/ |
| 626 | |
| 627 | /* get version of the firmware ROM, RTSL, video ucode and ARM application */ |
| 628 | int av7110_firmversion(struct av7110 *av7110) |
| 629 | { |
| 630 | u16 buf[20]; |
| 631 | u16 tag = ((COMTYPE_REQUEST << 8) + ReqVersion); |
| 632 | |
| 633 | dprintk(4, "%p\n", av7110); |
| 634 | |
| 635 | if (av7110_fw_query(av7110, tag, buf, 16)) { |
| 636 | printk("dvb-ttpci: failed to boot firmware @ card %d\n", |
Johannes Stezenbach | fdc53a6 | 2005-05-16 21:54:39 -0700 | [diff] [blame] | 637 | av7110->dvb_adapter.num); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 638 | return -EIO; |
| 639 | } |
| 640 | |
| 641 | av7110->arm_fw = (buf[0] << 16) + buf[1]; |
| 642 | av7110->arm_rtsl = (buf[2] << 16) + buf[3]; |
| 643 | av7110->arm_vid = (buf[4] << 16) + buf[5]; |
| 644 | av7110->arm_app = (buf[6] << 16) + buf[7]; |
| 645 | av7110->avtype = (buf[8] << 16) + buf[9]; |
| 646 | |
| 647 | printk("dvb-ttpci: info @ card %d: firm %08x, rtsl %08x, vid %08x, app %08x\n", |
Johannes Stezenbach | fdc53a6 | 2005-05-16 21:54:39 -0700 | [diff] [blame] | 648 | av7110->dvb_adapter.num, av7110->arm_fw, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | av7110->arm_rtsl, av7110->arm_vid, av7110->arm_app); |
| 650 | |
| 651 | /* print firmware capabilities */ |
| 652 | if (FW_CI_LL_SUPPORT(av7110->arm_app)) |
| 653 | printk("dvb-ttpci: firmware @ card %d supports CI link layer interface\n", |
Johannes Stezenbach | fdc53a6 | 2005-05-16 21:54:39 -0700 | [diff] [blame] | 654 | av7110->dvb_adapter.num); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | else |
| 656 | printk("dvb-ttpci: no firmware support for CI link layer interface @ card %d\n", |
Johannes Stezenbach | fdc53a6 | 2005-05-16 21:54:39 -0700 | [diff] [blame] | 657 | av7110->dvb_adapter.num); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 658 | |
| 659 | return 0; |
| 660 | } |
| 661 | |
| 662 | |
| 663 | int av7110_diseqc_send(struct av7110 *av7110, int len, u8 *msg, unsigned long burst) |
| 664 | { |
| 665 | int i, ret; |
| 666 | u16 buf[18] = { ((COMTYPE_AUDIODAC << 8) + SendDiSEqC), |
| 667 | 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; |
| 668 | |
| 669 | dprintk(4, "%p\n", av7110); |
| 670 | |
| 671 | if (len > 10) |
| 672 | len = 10; |
| 673 | |
| 674 | buf[1] = len + 2; |
| 675 | buf[2] = len; |
| 676 | |
| 677 | if (burst != -1) |
| 678 | buf[3] = burst ? 0x01 : 0x00; |
| 679 | else |
| 680 | buf[3] = 0xffff; |
| 681 | |
| 682 | for (i = 0; i < len; i++) |
| 683 | buf[i + 4] = msg[i]; |
| 684 | |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 685 | ret = av7110_send_fw_cmd(av7110, buf, 18); |
| 686 | if (ret && ret!=-ERESTARTSYS) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 687 | printk(KERN_ERR "dvb-ttpci: av7110_diseqc_send error %d\n", ret); |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 688 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 689 | } |
| 690 | |
| 691 | |
| 692 | #ifdef CONFIG_DVB_AV7110_OSD |
| 693 | |
| 694 | static inline int SetColorBlend(struct av7110 *av7110, u8 windownr) |
| 695 | { |
| 696 | return av7110_fw_cmd(av7110, COMTYPE_OSD, SetCBlend, 1, windownr); |
| 697 | } |
| 698 | |
| 699 | static inline int SetBlend_(struct av7110 *av7110, u8 windownr, |
| 700 | enum av7110_osd_palette_type colordepth, u16 index, u8 blending) |
| 701 | { |
| 702 | return av7110_fw_cmd(av7110, COMTYPE_OSD, SetBlend, 4, |
| 703 | windownr, colordepth, index, blending); |
| 704 | } |
| 705 | |
| 706 | static inline int SetColor_(struct av7110 *av7110, u8 windownr, |
| 707 | enum av7110_osd_palette_type colordepth, u16 index, u16 colorhi, u16 colorlo) |
| 708 | { |
| 709 | return av7110_fw_cmd(av7110, COMTYPE_OSD, SetColor, 5, |
| 710 | windownr, colordepth, index, colorhi, colorlo); |
| 711 | } |
| 712 | |
| 713 | static inline int SetFont(struct av7110 *av7110, u8 windownr, u8 fontsize, |
| 714 | u16 colorfg, u16 colorbg) |
| 715 | { |
| 716 | return av7110_fw_cmd(av7110, COMTYPE_OSD, Set_Font, 4, |
| 717 | windownr, fontsize, colorfg, colorbg); |
| 718 | } |
| 719 | |
| 720 | static int FlushText(struct av7110 *av7110) |
| 721 | { |
| 722 | unsigned long start; |
Oliver Endriss | 25de192 | 2005-07-07 17:58:28 -0700 | [diff] [blame] | 723 | int err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 724 | |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 725 | if (mutex_lock_interruptible(&av7110->dcomlock)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 726 | return -ERESTARTSYS; |
| 727 | start = jiffies; |
Oliver Endriss | 25de192 | 2005-07-07 17:58:28 -0700 | [diff] [blame] | 728 | while (1) { |
| 729 | err = time_after(jiffies, start + ARM_WAIT_OSD); |
| 730 | if (rdebi(av7110, DEBINOSWAP, BUFF1_BASE, 0, 2) == 0) |
| 731 | break; |
| 732 | if (err) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 733 | printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for BUFF1_BASE == 0\n", |
Harvey Harrison | 3ca7fc8 | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 734 | __func__); |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 735 | mutex_unlock(&av7110->dcomlock); |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 736 | return -ETIMEDOUT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 737 | } |
Johannes Stezenbach | 7d87bc3 | 2005-07-07 17:57:56 -0700 | [diff] [blame] | 738 | msleep(1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 739 | } |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 740 | mutex_unlock(&av7110->dcomlock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 741 | return 0; |
| 742 | } |
| 743 | |
Oliver Endriss | 804b445 | 2007-07-12 20:37:50 -0300 | [diff] [blame] | 744 | static int WriteText(struct av7110 *av7110, u8 win, u16 x, u16 y, char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 745 | { |
| 746 | int i, ret; |
| 747 | unsigned long start; |
| 748 | int length = strlen(buf) + 1; |
| 749 | u16 cbuf[5] = { (COMTYPE_OSD << 8) + DText, 3, win, x, y }; |
| 750 | |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 751 | if (mutex_lock_interruptible(&av7110->dcomlock)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 752 | return -ERESTARTSYS; |
| 753 | |
| 754 | start = jiffies; |
Oliver Endriss | 25de192 | 2005-07-07 17:58:28 -0700 | [diff] [blame] | 755 | while (1) { |
| 756 | ret = time_after(jiffies, start + ARM_WAIT_OSD); |
| 757 | if (rdebi(av7110, DEBINOSWAP, BUFF1_BASE, 0, 2) == 0) |
| 758 | break; |
| 759 | if (ret) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 760 | printk(KERN_ERR "dvb-ttpci: %s: timeout waiting for BUFF1_BASE == 0\n", |
Harvey Harrison | 3ca7fc8 | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 761 | __func__); |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 762 | mutex_unlock(&av7110->dcomlock); |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 763 | return -ETIMEDOUT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 764 | } |
Johannes Stezenbach | 7d87bc3 | 2005-07-07 17:57:56 -0700 | [diff] [blame] | 765 | msleep(1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 766 | } |
| 767 | #ifndef _NOHANDSHAKE |
| 768 | start = jiffies; |
Oliver Endriss | 25de192 | 2005-07-07 17:58:28 -0700 | [diff] [blame] | 769 | while (1) { |
| 770 | ret = time_after(jiffies, start + ARM_WAIT_SHAKE); |
| 771 | if (rdebi(av7110, DEBINOSWAP, HANDSHAKE_REG, 0, 2) == 0) |
| 772 | break; |
| 773 | if (ret) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 774 | printk(KERN_ERR "dvb-ttpci: %s: timeout waiting for HANDSHAKE_REG\n", |
Harvey Harrison | 3ca7fc8 | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 775 | __func__); |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 776 | mutex_unlock(&av7110->dcomlock); |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 777 | return -ETIMEDOUT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 778 | } |
Johannes Stezenbach | 7d87bc3 | 2005-07-07 17:57:56 -0700 | [diff] [blame] | 779 | msleep(1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 780 | } |
| 781 | #endif |
| 782 | for (i = 0; i < length / 2; i++) |
| 783 | wdebi(av7110, DEBINOSWAP, BUFF1_BASE + i * 2, |
| 784 | swab16(*(u16 *)(buf + 2 * i)), 2); |
| 785 | if (length & 1) |
| 786 | wdebi(av7110, DEBINOSWAP, BUFF1_BASE + i * 2, 0, 2); |
| 787 | ret = __av7110_send_fw_cmd(av7110, cbuf, 5); |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 788 | mutex_unlock(&av7110->dcomlock); |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 789 | if (ret && ret!=-ERESTARTSYS) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 790 | printk(KERN_ERR "dvb-ttpci: WriteText error %d\n", ret); |
| 791 | return ret; |
| 792 | } |
| 793 | |
| 794 | static inline int DrawLine(struct av7110 *av7110, u8 windownr, |
| 795 | u16 x, u16 y, u16 dx, u16 dy, u16 color) |
| 796 | { |
| 797 | return av7110_fw_cmd(av7110, COMTYPE_OSD, DLine, 6, |
| 798 | windownr, x, y, dx, dy, color); |
| 799 | } |
| 800 | |
| 801 | static inline int DrawBlock(struct av7110 *av7110, u8 windownr, |
| 802 | u16 x, u16 y, u16 dx, u16 dy, u16 color) |
| 803 | { |
| 804 | return av7110_fw_cmd(av7110, COMTYPE_OSD, DBox, 6, |
| 805 | windownr, x, y, dx, dy, color); |
| 806 | } |
| 807 | |
| 808 | static inline int HideWindow(struct av7110 *av7110, u8 windownr) |
| 809 | { |
| 810 | return av7110_fw_cmd(av7110, COMTYPE_OSD, WHide, 1, windownr); |
| 811 | } |
| 812 | |
| 813 | static inline int MoveWindowRel(struct av7110 *av7110, u8 windownr, u16 x, u16 y) |
| 814 | { |
| 815 | return av7110_fw_cmd(av7110, COMTYPE_OSD, WMoveD, 3, windownr, x, y); |
| 816 | } |
| 817 | |
| 818 | static inline int MoveWindowAbs(struct av7110 *av7110, u8 windownr, u16 x, u16 y) |
| 819 | { |
| 820 | return av7110_fw_cmd(av7110, COMTYPE_OSD, WMoveA, 3, windownr, x, y); |
| 821 | } |
| 822 | |
| 823 | static inline int DestroyOSDWindow(struct av7110 *av7110, u8 windownr) |
| 824 | { |
| 825 | return av7110_fw_cmd(av7110, COMTYPE_OSD, WDestroy, 1, windownr); |
| 826 | } |
| 827 | |
| 828 | static inline int CreateOSDWindow(struct av7110 *av7110, u8 windownr, |
| 829 | osd_raw_window_t disptype, |
| 830 | u16 width, u16 height) |
| 831 | { |
| 832 | return av7110_fw_cmd(av7110, COMTYPE_OSD, WCreate, 4, |
| 833 | windownr, disptype, width, height); |
| 834 | } |
| 835 | |
| 836 | |
| 837 | static enum av7110_osd_palette_type bpp2pal[8] = { |
| 838 | Pal1Bit, Pal2Bit, 0, Pal4Bit, 0, 0, 0, Pal8Bit |
| 839 | }; |
| 840 | static osd_raw_window_t bpp2bit[8] = { |
| 841 | OSD_BITMAP1, OSD_BITMAP2, 0, OSD_BITMAP4, 0, 0, 0, OSD_BITMAP8 |
| 842 | }; |
| 843 | |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 844 | static inline int WaitUntilBmpLoaded(struct av7110 *av7110) |
| 845 | { |
Oliver Endriss | 0b915e7 | 2008-06-19 23:10:14 -0300 | [diff] [blame] | 846 | int ret = wait_event_timeout(av7110->bmpq, |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 847 | av7110->bmp_state != BMP_LOADING, 10*HZ); |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 848 | if (ret == 0) { |
| 849 | printk("dvb-ttpci: warning: timeout waiting in LoadBitmap: %d, %d\n", |
| 850 | ret, av7110->bmp_state); |
| 851 | av7110->bmp_state = BMP_NONE; |
| 852 | return -ETIMEDOUT; |
| 853 | } |
| 854 | return 0; |
| 855 | } |
| 856 | |
| 857 | static inline int LoadBitmap(struct av7110 *av7110, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 858 | u16 dx, u16 dy, int inc, u8 __user * data) |
| 859 | { |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 860 | u16 format; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 861 | int bpp; |
| 862 | int i; |
| 863 | int d, delta; |
| 864 | u8 c; |
| 865 | int ret; |
| 866 | |
| 867 | dprintk(4, "%p\n", av7110); |
| 868 | |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 869 | format = bpp2bit[av7110->osdbpp[av7110->osdwin]]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 870 | |
| 871 | av7110->bmp_state = BMP_LOADING; |
| 872 | if (format == OSD_BITMAP8) { |
| 873 | bpp=8; delta = 1; |
| 874 | } else if (format == OSD_BITMAP4) { |
| 875 | bpp=4; delta = 2; |
| 876 | } else if (format == OSD_BITMAP2) { |
| 877 | bpp=2; delta = 4; |
| 878 | } else if (format == OSD_BITMAP1) { |
| 879 | bpp=1; delta = 8; |
| 880 | } else { |
| 881 | av7110->bmp_state = BMP_NONE; |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 882 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 883 | } |
| 884 | av7110->bmplen = ((dx * dy * bpp + 7) & ~7) / 8; |
| 885 | av7110->bmpp = 0; |
| 886 | if (av7110->bmplen > 32768) { |
| 887 | av7110->bmp_state = BMP_NONE; |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 888 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 889 | } |
| 890 | for (i = 0; i < dy; i++) { |
| 891 | if (copy_from_user(av7110->bmpbuf + 1024 + i * dx, data + i * inc, dx)) { |
| 892 | av7110->bmp_state = BMP_NONE; |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 893 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 894 | } |
| 895 | } |
| 896 | if (format != OSD_BITMAP8) { |
| 897 | for (i = 0; i < dx * dy / delta; i++) { |
| 898 | c = ((u8 *)av7110->bmpbuf)[1024 + i * delta + delta - 1]; |
| 899 | for (d = delta - 2; d >= 0; d--) { |
| 900 | c |= (((u8 *)av7110->bmpbuf)[1024 + i * delta + d] |
| 901 | << ((delta - d - 1) * bpp)); |
| 902 | ((u8 *)av7110->bmpbuf)[1024 + i] = c; |
| 903 | } |
| 904 | } |
| 905 | } |
| 906 | av7110->bmplen += 1024; |
| 907 | dprintk(4, "av7110_fw_cmd: LoadBmp size %d\n", av7110->bmplen); |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 908 | ret = av7110_fw_cmd(av7110, COMTYPE_OSD, LoadBmp, 3, format, dx, dy); |
| 909 | if (!ret) |
| 910 | ret = WaitUntilBmpLoaded(av7110); |
| 911 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 912 | } |
| 913 | |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 914 | static int BlitBitmap(struct av7110 *av7110, u16 x, u16 y) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 915 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 916 | dprintk(4, "%p\n", av7110); |
| 917 | |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 918 | return av7110_fw_cmd(av7110, COMTYPE_OSD, BlitBmp, 4, av7110->osdwin, x, y, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 919 | } |
| 920 | |
| 921 | static inline int ReleaseBitmap(struct av7110 *av7110) |
| 922 | { |
| 923 | dprintk(4, "%p\n", av7110); |
| 924 | |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 925 | if (av7110->bmp_state != BMP_LOADED && FW_VERSION(av7110->arm_app) < 0x261e) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 926 | return -1; |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 927 | if (av7110->bmp_state == BMP_LOADING) |
| 928 | dprintk(1,"ReleaseBitmap called while BMP_LOADING\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 929 | av7110->bmp_state = BMP_NONE; |
| 930 | return av7110_fw_cmd(av7110, COMTYPE_OSD, ReleaseBmp, 0); |
| 931 | } |
| 932 | |
| 933 | static u32 RGB2YUV(u16 R, u16 G, u16 B) |
| 934 | { |
| 935 | u16 y, u, v; |
| 936 | u16 Y, Cr, Cb; |
| 937 | |
| 938 | y = R * 77 + G * 150 + B * 29; /* Luma=0.299R+0.587G+0.114B 0..65535 */ |
| 939 | u = 2048 + B * 8 -(y >> 5); /* Cr 0..4095 */ |
| 940 | v = 2048 + R * 8 -(y >> 5); /* Cb 0..4095 */ |
| 941 | |
| 942 | Y = y / 256; |
| 943 | Cb = u / 16; |
| 944 | Cr = v / 16; |
| 945 | |
| 946 | return Cr | (Cb << 16) | (Y << 8); |
| 947 | } |
| 948 | |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 949 | static int OSDSetColor(struct av7110 *av7110, u8 color, u8 r, u8 g, u8 b, u8 blend) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 950 | { |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 951 | int ret; |
| 952 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 953 | u16 ch, cl; |
| 954 | u32 yuv; |
| 955 | |
| 956 | yuv = blend ? RGB2YUV(r,g,b) : 0; |
| 957 | cl = (yuv & 0xffff); |
| 958 | ch = ((yuv >> 16) & 0xffff); |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 959 | ret = SetColor_(av7110, av7110->osdwin, bpp2pal[av7110->osdbpp[av7110->osdwin]], |
| 960 | color, ch, cl); |
| 961 | if (!ret) |
| 962 | ret = SetBlend_(av7110, av7110->osdwin, bpp2pal[av7110->osdbpp[av7110->osdwin]], |
| 963 | color, ((blend >> 4) & 0x0f)); |
| 964 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 965 | } |
| 966 | |
| 967 | static int OSDSetPalette(struct av7110 *av7110, u32 __user * colors, u8 first, u8 last) |
| 968 | { |
Michael Krufky | b930e1d | 2007-08-27 18:16:54 -0300 | [diff] [blame] | 969 | int i; |
| 970 | int length = last - first + 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 971 | |
Michael Krufky | b930e1d | 2007-08-27 18:16:54 -0300 | [diff] [blame] | 972 | if (length * 4 > DATA_BUFF3_SIZE) |
| 973 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 974 | |
Michael Krufky | b930e1d | 2007-08-27 18:16:54 -0300 | [diff] [blame] | 975 | for (i = 0; i < length; i++) { |
| 976 | u32 color, blend, yuv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 977 | |
Michael Krufky | b930e1d | 2007-08-27 18:16:54 -0300 | [diff] [blame] | 978 | if (get_user(color, colors + i)) |
| 979 | return -EFAULT; |
| 980 | blend = (color & 0xF0000000) >> 4; |
| 981 | yuv = blend ? RGB2YUV(color & 0xFF, (color >> 8) & 0xFF, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 982 | (color >> 16) & 0xFF) | blend : 0; |
Michael Krufky | b930e1d | 2007-08-27 18:16:54 -0300 | [diff] [blame] | 983 | yuv = ((yuv & 0xFFFF0000) >> 16) | ((yuv & 0x0000FFFF) << 16); |
| 984 | wdebi(av7110, DEBINOSWAP, DATA_BUFF3_BASE + i * 4, yuv, 4); |
| 985 | } |
| 986 | return av7110_fw_cmd(av7110, COMTYPE_OSD, Set_Palette, 4, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 987 | av7110->osdwin, |
| 988 | bpp2pal[av7110->osdbpp[av7110->osdwin]], |
| 989 | first, last); |
| 990 | } |
| 991 | |
| 992 | static int OSDSetBlock(struct av7110 *av7110, int x0, int y0, |
| 993 | int x1, int y1, int inc, u8 __user * data) |
| 994 | { |
| 995 | uint w, h, bpp, bpl, size, lpb, bnum, brest; |
| 996 | int i; |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 997 | int rc,release_rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 998 | |
| 999 | w = x1 - x0 + 1; |
| 1000 | h = y1 - y0 + 1; |
| 1001 | if (inc <= 0) |
| 1002 | inc = w; |
| 1003 | if (w <= 0 || w > 720 || h <= 0 || h > 576) |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1004 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1005 | bpp = av7110->osdbpp[av7110->osdwin] + 1; |
| 1006 | bpl = ((w * bpp + 7) & ~7) / 8; |
| 1007 | size = h * bpl; |
| 1008 | lpb = (32 * 1024) / bpl; |
| 1009 | bnum = size / (lpb * bpl); |
| 1010 | brest = size - bnum * lpb * bpl; |
| 1011 | |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1012 | if (av7110->bmp_state == BMP_LOADING) { |
| 1013 | /* possible if syscall is repeated by -ERESTARTSYS and if firmware cannot abort */ |
| 1014 | BUG_ON (FW_VERSION(av7110->arm_app) >= 0x261e); |
| 1015 | rc = WaitUntilBmpLoaded(av7110); |
| 1016 | if (rc) |
| 1017 | return rc; |
| 1018 | /* just continue. This should work for all fw versions |
| 1019 | * if bnum==1 && !brest && LoadBitmap was successful |
| 1020 | */ |
| 1021 | } |
| 1022 | |
| 1023 | rc = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1024 | for (i = 0; i < bnum; i++) { |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1025 | rc = LoadBitmap(av7110, w, lpb, inc, data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1026 | if (rc) |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1027 | break; |
| 1028 | rc = BlitBitmap(av7110, x0, y0 + i * lpb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1029 | if (rc) |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1030 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1031 | data += lpb * inc; |
| 1032 | } |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1033 | if (!rc && brest) { |
| 1034 | rc = LoadBitmap(av7110, w, brest / bpl, inc, data); |
| 1035 | if (!rc) |
| 1036 | rc = BlitBitmap(av7110, x0, y0 + bnum * lpb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1037 | } |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1038 | release_rc = ReleaseBitmap(av7110); |
| 1039 | if (!rc) |
| 1040 | rc = release_rc; |
| 1041 | if (rc) |
| 1042 | dprintk(1,"returns %d\n",rc); |
| 1043 | return rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1044 | } |
| 1045 | |
| 1046 | int av7110_osd_cmd(struct av7110 *av7110, osd_cmd_t *dc) |
| 1047 | { |
| 1048 | int ret; |
| 1049 | |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 1050 | if (mutex_lock_interruptible(&av7110->osd_mutex)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1051 | return -ERESTARTSYS; |
| 1052 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1053 | switch (dc->cmd) { |
| 1054 | case OSD_Close: |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1055 | ret = DestroyOSDWindow(av7110, av7110->osdwin); |
| 1056 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1057 | case OSD_Open: |
| 1058 | av7110->osdbpp[av7110->osdwin] = (dc->color - 1) & 7; |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1059 | ret = CreateOSDWindow(av7110, av7110->osdwin, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1060 | bpp2bit[av7110->osdbpp[av7110->osdwin]], |
| 1061 | dc->x1 - dc->x0 + 1, dc->y1 - dc->y0 + 1); |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1062 | if (ret) |
| 1063 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1064 | if (!dc->data) { |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1065 | ret = MoveWindowAbs(av7110, av7110->osdwin, dc->x0, dc->y0); |
| 1066 | if (ret) |
| 1067 | break; |
| 1068 | ret = SetColorBlend(av7110, av7110->osdwin); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1069 | } |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1070 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1071 | case OSD_Show: |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1072 | ret = MoveWindowRel(av7110, av7110->osdwin, 0, 0); |
| 1073 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1074 | case OSD_Hide: |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1075 | ret = HideWindow(av7110, av7110->osdwin); |
| 1076 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1077 | case OSD_Clear: |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1078 | ret = DrawBlock(av7110, av7110->osdwin, 0, 0, 720, 576, 0); |
| 1079 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1080 | case OSD_Fill: |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1081 | ret = DrawBlock(av7110, av7110->osdwin, 0, 0, 720, 576, dc->color); |
| 1082 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1083 | case OSD_SetColor: |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1084 | ret = OSDSetColor(av7110, dc->color, dc->x0, dc->y0, dc->x1, dc->y1); |
| 1085 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1086 | case OSD_SetPalette: |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1087 | if (FW_VERSION(av7110->arm_app) >= 0x2618) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1088 | ret = OSDSetPalette(av7110, dc->data, dc->color, dc->x0); |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1089 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1090 | int i, len = dc->x0-dc->color+1; |
| 1091 | u8 __user *colors = (u8 __user *)dc->data; |
Alexey Klimov | 3763a8a | 2009-04-19 17:21:03 -0300 | [diff] [blame] | 1092 | u8 r, g = 0, b = 0, blend = 0; |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1093 | ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1094 | for (i = 0; i<len; i++) { |
| 1095 | if (get_user(r, colors + i * 4) || |
| 1096 | get_user(g, colors + i * 4 + 1) || |
| 1097 | get_user(b, colors + i * 4 + 2) || |
| 1098 | get_user(blend, colors + i * 4 + 3)) { |
| 1099 | ret = -EFAULT; |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1100 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1101 | } |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1102 | ret = OSDSetColor(av7110, dc->color + i, r, g, b, blend); |
| 1103 | if (ret) |
| 1104 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1105 | } |
| 1106 | } |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1107 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1108 | case OSD_SetPixel: |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1109 | ret = DrawLine(av7110, av7110->osdwin, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1110 | dc->x0, dc->y0, 0, 0, dc->color); |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1111 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1112 | case OSD_SetRow: |
| 1113 | dc->y1 = dc->y0; |
| 1114 | /* fall through */ |
| 1115 | case OSD_SetBlock: |
| 1116 | ret = OSDSetBlock(av7110, dc->x0, dc->y0, dc->x1, dc->y1, dc->color, dc->data); |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1117 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1118 | case OSD_FillRow: |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1119 | ret = DrawBlock(av7110, av7110->osdwin, dc->x0, dc->y0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1120 | dc->x1-dc->x0+1, dc->y1, dc->color); |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1121 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1122 | case OSD_FillBlock: |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1123 | ret = DrawBlock(av7110, av7110->osdwin, dc->x0, dc->y0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1124 | dc->x1 - dc->x0 + 1, dc->y1 - dc->y0 + 1, dc->color); |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1125 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1126 | case OSD_Line: |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1127 | ret = DrawLine(av7110, av7110->osdwin, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1128 | dc->x0, dc->y0, dc->x1 - dc->x0, dc->y1 - dc->y0, dc->color); |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1129 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1130 | case OSD_Text: |
| 1131 | { |
| 1132 | char textbuf[240]; |
| 1133 | |
| 1134 | if (strncpy_from_user(textbuf, dc->data, 240) < 0) { |
| 1135 | ret = -EFAULT; |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1136 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1137 | } |
| 1138 | textbuf[239] = 0; |
| 1139 | if (dc->x1 > 3) |
| 1140 | dc->x1 = 3; |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1141 | ret = SetFont(av7110, av7110->osdwin, dc->x1, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1142 | (u16) (dc->color & 0xffff), (u16) (dc->color >> 16)); |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1143 | if (!ret) |
| 1144 | ret = FlushText(av7110); |
| 1145 | if (!ret) |
| 1146 | ret = WriteText(av7110, av7110->osdwin, dc->x0, dc->y0, textbuf); |
| 1147 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1148 | } |
| 1149 | case OSD_SetWindow: |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1150 | if (dc->x0 < 1 || dc->x0 > 7) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1151 | ret = -EINVAL; |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1152 | else { |
| 1153 | av7110->osdwin = dc->x0; |
| 1154 | ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1155 | } |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1156 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1157 | case OSD_MoveWindow: |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1158 | ret = MoveWindowAbs(av7110, av7110->osdwin, dc->x0, dc->y0); |
| 1159 | if (!ret) |
| 1160 | ret = SetColorBlend(av7110, av7110->osdwin); |
| 1161 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1162 | case OSD_OpenRaw: |
| 1163 | if (dc->color < OSD_BITMAP1 || dc->color > OSD_CURSOR) { |
| 1164 | ret = -EINVAL; |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1165 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1166 | } |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1167 | if (dc->color >= OSD_BITMAP1 && dc->color <= OSD_BITMAP8HR) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1168 | av7110->osdbpp[av7110->osdwin] = (1 << (dc->color & 3)) - 1; |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1169 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1170 | av7110->osdbpp[av7110->osdwin] = 0; |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1171 | ret = CreateOSDWindow(av7110, av7110->osdwin, (osd_raw_window_t)dc->color, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1172 | dc->x1 - dc->x0 + 1, dc->y1 - dc->y0 + 1); |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1173 | if (ret) |
| 1174 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1175 | if (!dc->data) { |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1176 | ret = MoveWindowAbs(av7110, av7110->osdwin, dc->x0, dc->y0); |
| 1177 | if (!ret) |
| 1178 | ret = SetColorBlend(av7110, av7110->osdwin); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1179 | } |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1180 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1181 | default: |
| 1182 | ret = -EINVAL; |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1183 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1184 | } |
| 1185 | |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 1186 | mutex_unlock(&av7110->osd_mutex); |
Wolfgang Rohdewald | c9090eb | 2005-07-07 17:57:55 -0700 | [diff] [blame] | 1187 | if (ret==-ERESTARTSYS) |
| 1188 | dprintk(1, "av7110_osd_cmd(%d) returns with -ERESTARTSYS\n",dc->cmd); |
| 1189 | else if (ret) |
| 1190 | dprintk(1, "av7110_osd_cmd(%d) returns with %d\n",dc->cmd,ret); |
| 1191 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1192 | return ret; |
| 1193 | } |
| 1194 | |
| 1195 | int av7110_osd_capability(struct av7110 *av7110, osd_cap_t *cap) |
| 1196 | { |
Mauro Carvalho Chehab | 9101e62 | 2005-12-12 00:37:24 -0800 | [diff] [blame] | 1197 | switch (cap->cmd) { |
| 1198 | case OSD_CAP_MEMSIZE: |
| 1199 | if (FW_4M_SDRAM(av7110->arm_app)) |
Michael Krufky | 50c25ff | 2006-01-09 15:25:34 -0200 | [diff] [blame] | 1200 | cap->val = 1000000; |
Mauro Carvalho Chehab | 9101e62 | 2005-12-12 00:37:24 -0800 | [diff] [blame] | 1201 | else |
Michael Krufky | 50c25ff | 2006-01-09 15:25:34 -0200 | [diff] [blame] | 1202 | cap->val = 92000; |
Mauro Carvalho Chehab | 9101e62 | 2005-12-12 00:37:24 -0800 | [diff] [blame] | 1203 | return 0; |
| 1204 | default: |
| 1205 | return -EINVAL; |
| 1206 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1207 | } |
| 1208 | #endif /* CONFIG_DVB_AV7110_OSD */ |