Commit c9090ebb authored by Wolfgang Rohdewald's avatar Wolfgang Rohdewald Committed by Linus Torvalds

[PATCH] dvb: ttpci: fix error handling for firmware communication

o make sure ERESTARTSYS will be propagated
o ReleaseBitmap: starting with Firmware 261e, also release when
  BMP_LOADING
o removes unused #define BMP_LOADINGS
o in many cases changed the return value from -1 to something more
  meaningful like ETIMEDOUT, EINVAL
o changed syslog message timeout waiting for COMMAND such that it
  indicates what command did not complete
o reduce # of arguments for LoadBitmap and BlitBitmap
o av7110_osd_cmd: remove the out: label
Signed-off-by: default avatarWolfgang Rohdewald <wolfgang@rohdewald.de>
Signed-off-by: default avatarJohannes Stezenbach <js@linuxtv.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent dd2bbb17
...@@ -119,8 +119,7 @@ struct av7110 { ...@@ -119,8 +119,7 @@ struct av7110 {
volatile int bmp_state; volatile int bmp_state;
#define BMP_NONE 0 #define BMP_NONE 0
#define BMP_LOADING 1 #define BMP_LOADING 1
#define BMP_LOADINGS 2 #define BMP_LOADED 2
#define BMP_LOADED 3
wait_queue_head_t bmpq; wait_queue_head_t bmpq;
......
...@@ -137,7 +137,7 @@ static int waitdebi(struct av7110 *av7110, int adr, int state) ...@@ -137,7 +137,7 @@ static int waitdebi(struct av7110 *av7110, int adr, int state)
return 0; return 0;
udelay(5); udelay(5);
} }
return -1; return -ETIMEDOUT;
} }
static int load_dram(struct av7110 *av7110, u32 *data, int len) static int load_dram(struct av7110 *av7110, u32 *data, int len)
...@@ -155,7 +155,7 @@ static int load_dram(struct av7110 *av7110, u32 *data, int len) ...@@ -155,7 +155,7 @@ static int load_dram(struct av7110 *av7110, u32 *data, int len)
for (i = 0; i < blocks; i++) { for (i = 0; i < blocks; i++) {
if (waitdebi(av7110, BOOT_STATE, BOOTSTATE_BUFFER_EMPTY) < 0) { if (waitdebi(av7110, BOOT_STATE, BOOTSTATE_BUFFER_EMPTY) < 0) {
printk(KERN_ERR "dvb-ttpci: load_dram(): timeout at block %d\n", i); printk(KERN_ERR "dvb-ttpci: load_dram(): timeout at block %d\n", i);
return -1; return -ETIMEDOUT;
} }
dprintk(4, "writing DRAM block %d\n", i); dprintk(4, "writing DRAM block %d\n", i);
mwdebi(av7110, DEBISWAB, bootblock, mwdebi(av7110, DEBISWAB, bootblock,
...@@ -170,7 +170,7 @@ static int load_dram(struct av7110 *av7110, u32 *data, int len) ...@@ -170,7 +170,7 @@ static int load_dram(struct av7110 *av7110, u32 *data, int len)
if (rest > 0) { if (rest > 0) {
if (waitdebi(av7110, BOOT_STATE, BOOTSTATE_BUFFER_EMPTY) < 0) { if (waitdebi(av7110, BOOT_STATE, BOOTSTATE_BUFFER_EMPTY) < 0) {
printk(KERN_ERR "dvb-ttpci: load_dram(): timeout at last block\n"); printk(KERN_ERR "dvb-ttpci: load_dram(): timeout at last block\n");
return -1; return -ETIMEDOUT;
} }
if (rest > 4) if (rest > 4)
mwdebi(av7110, DEBISWAB, bootblock, mwdebi(av7110, DEBISWAB, bootblock,
...@@ -185,13 +185,13 @@ static int load_dram(struct av7110 *av7110, u32 *data, int len) ...@@ -185,13 +185,13 @@ static int load_dram(struct av7110 *av7110, u32 *data, int len)
} }
if (waitdebi(av7110, BOOT_STATE, BOOTSTATE_BUFFER_EMPTY) < 0) { if (waitdebi(av7110, BOOT_STATE, BOOTSTATE_BUFFER_EMPTY) < 0) {
printk(KERN_ERR "dvb-ttpci: load_dram(): timeout after last block\n"); printk(KERN_ERR "dvb-ttpci: load_dram(): timeout after last block\n");
return -1; return -ETIMEDOUT;
} }
iwdebi(av7110, DEBINOSWAP, BOOT_SIZE, 0, 2); iwdebi(av7110, DEBINOSWAP, BOOT_SIZE, 0, 2);
iwdebi(av7110, DEBINOSWAP, BOOT_STATE, BOOTSTATE_BUFFER_FULL, 2); iwdebi(av7110, DEBINOSWAP, BOOT_STATE, BOOTSTATE_BUFFER_FULL, 2);
if (waitdebi(av7110, BOOT_STATE, BOOTSTATE_BOOT_COMPLETE) < 0) { if (waitdebi(av7110, BOOT_STATE, BOOTSTATE_BOOT_COMPLETE) < 0) {
printk(KERN_ERR "dvb-ttpci: load_dram(): final handshake timeout\n"); printk(KERN_ERR "dvb-ttpci: load_dram(): final handshake timeout\n");
return -1; return -ETIMEDOUT;
} }
return 0; return 0;
} }
...@@ -263,7 +263,7 @@ int av7110_bootarm(struct av7110 *av7110) ...@@ -263,7 +263,7 @@ int av7110_bootarm(struct av7110 *av7110)
if (saa7146_wait_for_debi_done(av7110->dev, 1)) { if (saa7146_wait_for_debi_done(av7110->dev, 1)) {
printk(KERN_ERR "dvb-ttpci: av7110_bootarm(): " printk(KERN_ERR "dvb-ttpci: av7110_bootarm(): "
"saa7146_wait_for_debi_done() timed out\n"); "saa7146_wait_for_debi_done() timed out\n");
return -1; return -ETIMEDOUT;
} }
saa7146_setgpio(dev, RESET_LINE, SAA7146_GPIO_OUTHI); saa7146_setgpio(dev, RESET_LINE, SAA7146_GPIO_OUTHI);
mdelay(1); mdelay(1);
...@@ -284,7 +284,7 @@ int av7110_bootarm(struct av7110 *av7110) ...@@ -284,7 +284,7 @@ int av7110_bootarm(struct av7110 *av7110)
if (saa7146_wait_for_debi_done(av7110->dev, 1)) { if (saa7146_wait_for_debi_done(av7110->dev, 1)) {
printk(KERN_ERR "dvb-ttpci: av7110_bootarm(): " printk(KERN_ERR "dvb-ttpci: av7110_bootarm(): "
"saa7146_wait_for_debi_done() timed out after loading DRAM\n"); "saa7146_wait_for_debi_done() timed out after loading DRAM\n");
return -1; return -ETIMEDOUT;
} }
saa7146_setgpio(dev, RESET_LINE, SAA7146_GPIO_OUTHI); saa7146_setgpio(dev, RESET_LINE, SAA7146_GPIO_OUTHI);
msleep(30); /* the firmware needs some time to initialize */ msleep(30); /* the firmware needs some time to initialize */
...@@ -328,7 +328,7 @@ int av7110_wait_msgstate(struct av7110 *av7110, u16 flags) ...@@ -328,7 +328,7 @@ int av7110_wait_msgstate(struct av7110 *av7110, u16 flags)
if (time_after(jiffies, start + ARM_WAIT_FREE)) { if (time_after(jiffies, start + ARM_WAIT_FREE)) {
printk(KERN_ERR "%s: timeout waiting for MSGSTATE %04x\n", printk(KERN_ERR "%s: timeout waiting for MSGSTATE %04x\n",
__FUNCTION__, stat & flags); __FUNCTION__, stat & flags);
return -1; return -ETIMEDOUT;
} }
msleep(1); msleep(1);
} }
...@@ -412,7 +412,7 @@ static int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length) ...@@ -412,7 +412,7 @@ static int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length)
if (time_after(jiffies, start + ARM_WAIT_FREE)) { if (time_after(jiffies, start + ARM_WAIT_FREE)) {
printk(KERN_ERR "%s: timeout waiting on busy %s QUEUE\n", printk(KERN_ERR "%s: timeout waiting on busy %s QUEUE\n",
__FUNCTION__, type); __FUNCTION__, type);
return -1; return -ETIMEDOUT;
} }
msleep(1); msleep(1);
} }
...@@ -435,8 +435,10 @@ static int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length) ...@@ -435,8 +435,10 @@ static int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length)
while (rdebi(av7110, DEBINOSWAP, COMMAND, 0, 2 )) { while (rdebi(av7110, DEBINOSWAP, COMMAND, 0, 2 )) {
msleep(1); msleep(1);
if (time_after(jiffies, start + ARM_WAIT_FREE)) { if (time_after(jiffies, start + ARM_WAIT_FREE)) {
printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for COMMAND to complete\n", printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for COMMAND %d to complete\n",
__FUNCTION__); __FUNCTION__,
(buf[0] >> 8) & 0xff
);
return -ETIMEDOUT; return -ETIMEDOUT;
} }
} }
...@@ -470,7 +472,7 @@ static int av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length) ...@@ -470,7 +472,7 @@ static int av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length)
ret = __av7110_send_fw_cmd(av7110, buf, length); ret = __av7110_send_fw_cmd(av7110, buf, length);
up(&av7110->dcomlock); up(&av7110->dcomlock);
if (ret) if (ret && ret!=-ERESTARTSYS)
printk(KERN_ERR "dvb-ttpci: %s(): av7110_send_fw_cmd error %d\n", printk(KERN_ERR "dvb-ttpci: %s(): av7110_send_fw_cmd error %d\n",
__FUNCTION__, ret); __FUNCTION__, ret);
return ret; return ret;
...@@ -495,7 +497,7 @@ int av7110_fw_cmd(struct av7110 *av7110, int type, int com, int num, ...) ...@@ -495,7 +497,7 @@ int av7110_fw_cmd(struct av7110 *av7110, int type, int com, int num, ...)
} }
ret = av7110_send_fw_cmd(av7110, buf, num + 2); ret = av7110_send_fw_cmd(av7110, buf, num + 2);
if (ret) if (ret && ret != -ERESTARTSYS)
printk(KERN_ERR "dvb-ttpci: av7110_fw_cmd error %d\n", ret); printk(KERN_ERR "dvb-ttpci: av7110_fw_cmd error %d\n", ret);
return ret; return ret;
} }
...@@ -518,7 +520,7 @@ int av7110_send_ci_cmd(struct av7110 *av7110, u8 subcom, u8 *buf, u8 len) ...@@ -518,7 +520,7 @@ int av7110_send_ci_cmd(struct av7110 *av7110, u8 subcom, u8 *buf, u8 len)
} }
ret = av7110_send_fw_cmd(av7110, cmd, 18); ret = av7110_send_fw_cmd(av7110, cmd, 18);
if (ret) if (ret && ret != -ERESTARTSYS)
printk(KERN_ERR "dvb-ttpci: av7110_send_ci_cmd error %d\n", ret); printk(KERN_ERR "dvb-ttpci: av7110_send_ci_cmd error %d\n", ret);
return ret; return ret;
} }
...@@ -558,7 +560,7 @@ int av7110_fw_request(struct av7110 *av7110, u16 *request_buf, ...@@ -558,7 +560,7 @@ int av7110_fw_request(struct av7110 *av7110, u16 *request_buf,
if (time_after(jiffies, start + ARM_WAIT_FREE)) { if (time_after(jiffies, start + ARM_WAIT_FREE)) {
printk(KERN_ERR "%s: timeout waiting for COMMAND to complete\n", __FUNCTION__); printk(KERN_ERR "%s: timeout waiting for COMMAND to complete\n", __FUNCTION__);
up(&av7110->dcomlock); up(&av7110->dcomlock);
return -1; return -ETIMEDOUT;
} }
} }
...@@ -569,7 +571,7 @@ int av7110_fw_request(struct av7110 *av7110, u16 *request_buf, ...@@ -569,7 +571,7 @@ int av7110_fw_request(struct av7110 *av7110, u16 *request_buf,
if (time_after(jiffies, start + ARM_WAIT_SHAKE)) { if (time_after(jiffies, start + ARM_WAIT_SHAKE)) {
printk(KERN_ERR "%s: timeout waiting for HANDSHAKE_REG\n", __FUNCTION__); printk(KERN_ERR "%s: timeout waiting for HANDSHAKE_REG\n", __FUNCTION__);
up(&av7110->dcomlock); up(&av7110->dcomlock);
return -1; return -ETIMEDOUT;
} }
} }
#endif #endif
...@@ -667,10 +669,10 @@ int av7110_diseqc_send(struct av7110 *av7110, int len, u8 *msg, unsigned long bu ...@@ -667,10 +669,10 @@ int av7110_diseqc_send(struct av7110 *av7110, int len, u8 *msg, unsigned long bu
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
buf[i + 4] = msg[i]; buf[i + 4] = msg[i];
if ((ret = av7110_send_fw_cmd(av7110, buf, 18))) ret = av7110_send_fw_cmd(av7110, buf, 18);
if (ret && ret!=-ERESTARTSYS)
printk(KERN_ERR "dvb-ttpci: av7110_diseqc_send error %d\n", ret); printk(KERN_ERR "dvb-ttpci: av7110_diseqc_send error %d\n", ret);
return ret;
return 0;
} }
...@@ -715,7 +717,7 @@ static int FlushText(struct av7110 *av7110) ...@@ -715,7 +717,7 @@ static int FlushText(struct av7110 *av7110)
printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for BUFF1_BASE == 0\n", printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for BUFF1_BASE == 0\n",
__FUNCTION__); __FUNCTION__);
up(&av7110->dcomlock); up(&av7110->dcomlock);
return -1; return -ETIMEDOUT;
} }
} }
up(&av7110->dcomlock); up(&av7110->dcomlock);
...@@ -739,7 +741,7 @@ static int WriteText(struct av7110 *av7110, u8 win, u16 x, u16 y, u8* buf) ...@@ -739,7 +741,7 @@ static int WriteText(struct av7110 *av7110, u8 win, u16 x, u16 y, u8* buf)
printk(KERN_ERR "dvb-ttpci: %s: timeout waiting for BUFF1_BASE == 0\n", printk(KERN_ERR "dvb-ttpci: %s: timeout waiting for BUFF1_BASE == 0\n",
__FUNCTION__); __FUNCTION__);
up(&av7110->dcomlock); up(&av7110->dcomlock);
return -1; return -ETIMEDOUT;
} }
} }
#ifndef _NOHANDSHAKE #ifndef _NOHANDSHAKE
...@@ -750,7 +752,7 @@ static int WriteText(struct av7110 *av7110, u8 win, u16 x, u16 y, u8* buf) ...@@ -750,7 +752,7 @@ static int WriteText(struct av7110 *av7110, u8 win, u16 x, u16 y, u8* buf)
printk(KERN_ERR "dvb-ttpci: %s: timeout waiting for HANDSHAKE_REG\n", printk(KERN_ERR "dvb-ttpci: %s: timeout waiting for HANDSHAKE_REG\n",
__FUNCTION__); __FUNCTION__);
up(&av7110->dcomlock); up(&av7110->dcomlock);
return -1; return -ETIMEDOUT;
} }
} }
#endif #endif
...@@ -761,7 +763,7 @@ static int WriteText(struct av7110 *av7110, u8 win, u16 x, u16 y, u8* buf) ...@@ -761,7 +763,7 @@ static int WriteText(struct av7110 *av7110, u8 win, u16 x, u16 y, u8* buf)
wdebi(av7110, DEBINOSWAP, BUFF1_BASE + i * 2, 0, 2); wdebi(av7110, DEBINOSWAP, BUFF1_BASE + i * 2, 0, 2);
ret = __av7110_send_fw_cmd(av7110, cbuf, 5); ret = __av7110_send_fw_cmd(av7110, cbuf, 5);
up(&av7110->dcomlock); up(&av7110->dcomlock);
if (ret) if (ret && ret!=-ERESTARTSYS)
printk(KERN_ERR "dvb-ttpci: WriteText error %d\n", ret); printk(KERN_ERR "dvb-ttpci: WriteText error %d\n", ret);
return ret; return ret;
} }
...@@ -816,9 +818,25 @@ static osd_raw_window_t bpp2bit[8] = { ...@@ -816,9 +818,25 @@ static osd_raw_window_t bpp2bit[8] = {
OSD_BITMAP1, OSD_BITMAP2, 0, OSD_BITMAP4, 0, 0, 0, OSD_BITMAP8 OSD_BITMAP1, OSD_BITMAP2, 0, OSD_BITMAP4, 0, 0, 0, OSD_BITMAP8
}; };
static inline int LoadBitmap(struct av7110 *av7110, u16 format, static inline int WaitUntilBmpLoaded(struct av7110 *av7110)
{
int ret = wait_event_interruptible_timeout(av7110->bmpq,
av7110->bmp_state != BMP_LOADING, 10*HZ);
if (ret == -ERESTARTSYS)
return ret;
if (ret == 0) {
printk("dvb-ttpci: warning: timeout waiting in LoadBitmap: %d, %d\n",
ret, av7110->bmp_state);
av7110->bmp_state = BMP_NONE;
return -ETIMEDOUT;
}
return 0;
}
static inline int LoadBitmap(struct av7110 *av7110,
u16 dx, u16 dy, int inc, u8 __user * data) u16 dx, u16 dy, int inc, u8 __user * data)
{ {
u16 format;
int bpp; int bpp;
int i; int i;
int d, delta; int d, delta;
...@@ -827,14 +845,7 @@ static inline int LoadBitmap(struct av7110 *av7110, u16 format, ...@@ -827,14 +845,7 @@ static inline int LoadBitmap(struct av7110 *av7110, u16 format,
dprintk(4, "%p\n", av7110); dprintk(4, "%p\n", av7110);
ret = wait_event_interruptible_timeout(av7110->bmpq, av7110->bmp_state != BMP_LOADING, HZ); format = bpp2bit[av7110->osdbpp[av7110->osdwin]];
if (ret == -ERESTARTSYS || ret == 0) {
printk("dvb-ttpci: warning: timeout waiting in LoadBitmap: %d, %d\n",
ret, av7110->bmp_state);
av7110->bmp_state = BMP_NONE;
return -1;
}
BUG_ON (av7110->bmp_state == BMP_LOADING);
av7110->bmp_state = BMP_LOADING; av7110->bmp_state = BMP_LOADING;
if (format == OSD_BITMAP8) { if (format == OSD_BITMAP8) {
...@@ -847,18 +858,18 @@ static inline int LoadBitmap(struct av7110 *av7110, u16 format, ...@@ -847,18 +858,18 @@ static inline int LoadBitmap(struct av7110 *av7110, u16 format,
bpp=1; delta = 8; bpp=1; delta = 8;
} else { } else {
av7110->bmp_state = BMP_NONE; av7110->bmp_state = BMP_NONE;
return -1; return -EINVAL;
} }
av7110->bmplen = ((dx * dy * bpp + 7) & ~7) / 8; av7110->bmplen = ((dx * dy * bpp + 7) & ~7) / 8;
av7110->bmpp = 0; av7110->bmpp = 0;
if (av7110->bmplen > 32768) { if (av7110->bmplen > 32768) {
av7110->bmp_state = BMP_NONE; av7110->bmp_state = BMP_NONE;
return -1; return -EINVAL;
} }
for (i = 0; i < dy; i++) { for (i = 0; i < dy; i++) {
if (copy_from_user(av7110->bmpbuf + 1024 + i * dx, data + i * inc, dx)) { if (copy_from_user(av7110->bmpbuf + 1024 + i * dx, data + i * inc, dx)) {
av7110->bmp_state = BMP_NONE; av7110->bmp_state = BMP_NONE;
return -1; return -EINVAL;
} }
} }
if (format != OSD_BITMAP8) { if (format != OSD_BITMAP8) {
...@@ -873,37 +884,27 @@ static inline int LoadBitmap(struct av7110 *av7110, u16 format, ...@@ -873,37 +884,27 @@ static inline int LoadBitmap(struct av7110 *av7110, u16 format,
} }
av7110->bmplen += 1024; av7110->bmplen += 1024;
dprintk(4, "av7110_fw_cmd: LoadBmp size %d\n", av7110->bmplen); dprintk(4, "av7110_fw_cmd: LoadBmp size %d\n", av7110->bmplen);
return av7110_fw_cmd(av7110, COMTYPE_OSD, LoadBmp, 3, format, dx, dy); ret = av7110_fw_cmd(av7110, COMTYPE_OSD, LoadBmp, 3, format, dx, dy);
if (!ret)
ret = WaitUntilBmpLoaded(av7110);
return ret;
} }
static int BlitBitmap(struct av7110 *av7110, u16 win, u16 x, u16 y, u16 trans) static int BlitBitmap(struct av7110 *av7110, u16 x, u16 y)
{ {
int ret;
dprintk(4, "%p\n", av7110); dprintk(4, "%p\n", av7110);
BUG_ON (av7110->bmp_state == BMP_NONE); return av7110_fw_cmd(av7110, COMTYPE_OSD, BlitBmp, 4, av7110->osdwin, x, y, 0);
ret = wait_event_interruptible_timeout(av7110->bmpq,
av7110->bmp_state != BMP_LOADING, 10*HZ);
if (ret == -ERESTARTSYS || ret == 0) {
printk("dvb-ttpci: warning: timeout waiting in BlitBitmap: %d, %d\n",
ret, av7110->bmp_state);
av7110->bmp_state = BMP_NONE;
return (ret == 0) ? -ETIMEDOUT : ret;
}
BUG_ON (av7110->bmp_state != BMP_LOADED);
return av7110_fw_cmd(av7110, COMTYPE_OSD, BlitBmp, 4, win, x, y, trans);
} }
static inline int ReleaseBitmap(struct av7110 *av7110) static inline int ReleaseBitmap(struct av7110 *av7110)
{ {
dprintk(4, "%p\n", av7110); dprintk(4, "%p\n", av7110);
if (av7110->bmp_state != BMP_LOADED) if (av7110->bmp_state != BMP_LOADED && FW_VERSION(av7110->arm_app) < 0x261e)
return -1; return -1;
if (av7110->bmp_state == BMP_LOADING)
dprintk(1,"ReleaseBitmap called while BMP_LOADING\n");
av7110->bmp_state = BMP_NONE; av7110->bmp_state = BMP_NONE;
return av7110_fw_cmd(av7110, COMTYPE_OSD, ReleaseBmp, 0); return av7110_fw_cmd(av7110, COMTYPE_OSD, ReleaseBmp, 0);
} }
...@@ -924,18 +925,22 @@ static u32 RGB2YUV(u16 R, u16 G, u16 B) ...@@ -924,18 +925,22 @@ static u32 RGB2YUV(u16 R, u16 G, u16 B)
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) static int OSDSetColor(struct av7110 *av7110, u8 color, u8 r, u8 g, u8 b, u8 blend)
{ {
int ret;
u16 ch, cl; u16 ch, cl;
u32 yuv; u32 yuv;
yuv = blend ? RGB2YUV(r,g,b) : 0; yuv = blend ? RGB2YUV(r,g,b) : 0;
cl = (yuv & 0xffff); cl = (yuv & 0xffff);
ch = ((yuv >> 16) & 0xffff); ch = ((yuv >> 16) & 0xffff);
SetColor_(av7110, av7110->osdwin, bpp2pal[av7110->osdbpp[av7110->osdwin]], ret = SetColor_(av7110, av7110->osdwin, bpp2pal[av7110->osdbpp[av7110->osdwin]],
color, ch, cl); color, ch, cl);
SetBlend_(av7110, av7110->osdwin, bpp2pal[av7110->osdbpp[av7110->osdwin]], if (!ret)
color, ((blend >> 4) & 0x0f)); ret = SetBlend_(av7110, av7110->osdwin, bpp2pal[av7110->osdbpp[av7110->osdwin]],
color, ((blend >> 4) & 0x0f));
return ret;
} }
static int OSDSetPalette(struct av7110 *av7110, u32 __user * colors, u8 first, u8 last) static int OSDSetPalette(struct av7110 *av7110, u32 __user * colors, u8 first, u8 last)
...@@ -968,14 +973,14 @@ static int OSDSetBlock(struct av7110 *av7110, int x0, int y0, ...@@ -968,14 +973,14 @@ static int OSDSetBlock(struct av7110 *av7110, int x0, int y0,
{ {
uint w, h, bpp, bpl, size, lpb, bnum, brest; uint w, h, bpp, bpl, size, lpb, bnum, brest;
int i; int i;
int rc; int rc,release_rc;
w = x1 - x0 + 1; w = x1 - x0 + 1;
h = y1 - y0 + 1; h = y1 - y0 + 1;
if (inc <= 0) if (inc <= 0)
inc = w; inc = w;
if (w <= 0 || w > 720 || h <= 0 || h > 576) if (w <= 0 || w > 720 || h <= 0 || h > 576)
return -1; return -EINVAL;
bpp = av7110->osdbpp[av7110->osdwin] + 1; bpp = av7110->osdbpp[av7110->osdwin] + 1;
bpl = ((w * bpp + 7) & ~7) / 8; bpl = ((w * bpp + 7) & ~7) / 8;
size = h * bpl; size = h * bpl;
...@@ -983,176 +988,186 @@ static int OSDSetBlock(struct av7110 *av7110, int x0, int y0, ...@@ -983,176 +988,186 @@ static int OSDSetBlock(struct av7110 *av7110, int x0, int y0,
bnum = size / (lpb * bpl); bnum = size / (lpb * bpl);
brest = size - bnum * lpb * bpl; brest = size - bnum * lpb * bpl;
for (i = 0; i < bnum; i++) { if (av7110->bmp_state == BMP_LOADING) {
rc = LoadBitmap(av7110, bpp2bit[av7110->osdbpp[av7110->osdwin]], /* possible if syscall is repeated by -ERESTARTSYS and if firmware cannot abort */
w, lpb, inc, data); BUG_ON (FW_VERSION(av7110->arm_app) >= 0x261e);
if (rc) rc = WaitUntilBmpLoaded(av7110);
return rc;
rc = BlitBitmap(av7110, av7110->osdwin, x0, y0 + i * lpb, 0);
if (rc) if (rc)
return rc; return rc;
data += lpb * inc; /* just continue. This should work for all fw versions
* if bnum==1 && !brest && LoadBitmap was successful
*/
} }
if (brest) {
rc = LoadBitmap(av7110, bpp2bit[av7110->osdbpp[av7110->osdwin]], rc = 0;
w, brest / bpl, inc, data); for (i = 0; i < bnum; i++) {
rc = LoadBitmap(av7110, w, lpb, inc, data);
if (rc) if (rc)
return rc; break;
rc = BlitBitmap(av7110, av7110->osdwin, x0, y0 + bnum * lpb, 0); rc = BlitBitmap(av7110, x0, y0 + i * lpb);
if (rc) if (rc)
return rc; break;
data += lpb * inc;
} }
ReleaseBitmap(av7110); if (!rc && brest) {
return 0; rc = LoadBitmap(av7110, w, brest / bpl, inc, data);
if (!rc)
rc = BlitBitmap(av7110, x0, y0 + bnum * lpb);
}
release_rc = ReleaseBitmap(av7110);
if (!rc)
rc = release_rc;
if (rc)
dprintk(1,"returns %d\n",rc);
return rc;
} }
int av7110_osd_cmd(struct av7110 *av7110, osd_cmd_t *dc) int av7110_osd_cmd(struct av7110 *av7110, osd_cmd_t *dc)
{ {
int ret; int ret;
ret = down_interruptible(&av7110->osd_sema); if (down_interruptible(&av7110->osd_sema))
if (ret)
return -ERESTARTSYS; return -ERESTARTSYS;
/* stupid, but OSD functions don't provide a return code anyway */
ret = 0;
switch (dc->cmd) { switch (dc->cmd) {
case OSD_Close: case OSD_Close:
DestroyOSDWindow(av7110, av7110->osdwin); ret = DestroyOSDWindow(av7110, av7110->osdwin);
goto out; break;
case OSD_Open: case OSD_Open:
av7110->osdbpp[av7110->osdwin] = (dc->color - 1) & 7; av7110->osdbpp[av7110->osdwin] = (dc->color - 1) & 7;
CreateOSDWindow(av7110, av7110->osdwin, ret = CreateOSDWindow(av7110, av7110->osdwin,
bpp2bit[av7110->osdbpp[av7110->osdwin]], bpp2bit[av7110->osdbpp[av7110->osdwin]],
dc->x1 - dc->x0 + 1, dc->y1 - dc->y0 + 1); dc->x1 - dc->x0 + 1, dc->y1 - dc->y0 + 1);
if (ret)
break;
if (!dc->data) { if (!dc->data) {
MoveWindowAbs(av7110, av7110->osdwin, dc->x0, dc->y0); ret = MoveWindowAbs(av7110, av7110->osdwin, dc->x0, dc->y0);
SetColorBlend(av7110, av7110->osdwin); if (ret)
break;
ret = SetColorBlend(av7110, av7110->osdwin);
} }
goto out; break;
case OSD_Show: case OSD_Show:
MoveWindowRel(av7110, av7110->osdwin, 0, 0); ret = MoveWindowRel(av7110, av7110->osdwin, 0, 0);
goto out; break;
case OSD_Hide: case OSD_Hide:
HideWindow(av7110, av7110->osdwin); ret = HideWindow(av7110, av7110->osdwin);
goto out; break;
case OSD_Clear: case OSD_Clear:
DrawBlock(av7110, av7110->osdwin, 0, 0, 720, 576, 0); ret = DrawBlock(av7110, av7110->osdwin, 0, 0, 720, 576, 0);
goto out; break;
case OSD_Fill: case OSD_Fill:
DrawBlock(av7110, av7110->osdwin, 0, 0, 720, 576, dc->color); ret = DrawBlock(av7110, av7110->osdwin, 0, 0, 720, 576, dc->color);
goto out; break;
case OSD_SetColor: case OSD_SetColor:
OSDSetColor(av7110, dc->color, dc->x0, dc->y0, dc->x1, dc->y1); ret = OSDSetColor(av7110, dc->color, dc->x0, dc->y0, dc->x1, dc->y1);
goto out; break;
case OSD_SetPalette: case OSD_SetPalette:
{ if (FW_VERSION(av7110->arm_app) >= 0x2618)
if (FW_VERSION(av7110->arm_app) >= 0x2618) {
ret = OSDSetPalette(av7110, dc->data, dc->color, dc->x0); ret = OSDSetPalette(av7110, dc->data, dc->color, dc->x0);
goto out; else {
} else {
int i, len = dc->x0-dc->color+1; int i, len = dc->x0-dc->color+1;
u8 __user *colors = (u8 __user *)dc->data; u8 __user *colors = (u8 __user *)dc->data;
u8 r, g, b, blend; u8 r, g, b, blend;
ret = 0;
for (i = 0; i<len; i++) { for (i = 0; i<len; i++) {
if (get_user(r, colors + i * 4) || if (get_user(r, colors + i * 4) ||
get_user(g, colors + i * 4 + 1) || get_user(g, colors + i * 4 + 1) ||
get_user(b, colors + i * 4 + 2) || get_user(b, colors + i * 4 + 2) ||
get_user(blend, colors + i * 4 + 3)) { get_user(blend, colors + i * 4 + 3)) {
ret = -EFAULT; ret = -EFAULT;
goto out; break;
} }
OSDSetColor(av7110, dc->color + i, r, g, b, blend); ret = OSDSetColor(av7110, dc->color + i, r, g, b, blend);
if (ret)
break;
} }
} }
ret = 0; break;
goto out;
}
case OSD_SetTrans:
goto out;
case OSD_SetPixel: case OSD_SetPixel:
DrawLine(av7110, av7110->osdwin, ret = DrawLine(av7110, av7110->osdwin,
dc->x0, dc->y0, 0, 0, dc->color); dc->x0, dc->y0, 0, 0, dc->color);
goto out; break;
case OSD_GetPixel:
goto out;
case OSD_SetRow: case OSD_SetRow:
dc->y1 = dc->y0; dc->y1 = dc->y0;
/* fall through */ /* fall through */
case OSD_SetBlock: case OSD_SetBlock:
ret = OSDSetBlock(av7110, dc->x0, dc->y0, dc->x1, dc->y1, dc->color, dc->data); ret = OSDSetBlock(av7110, dc->x0, dc->y0, dc->x1, dc->y1, dc->color, dc->data);
goto out; break;
case OSD_FillRow: case OSD_FillRow:
DrawBlock(av7110, av7110->osdwin, dc->x0, dc->y0, ret = DrawBlock(av7110, av7110->osdwin, dc->x0, dc->y0,
dc->x1-dc->x0+1, dc->y1, dc->color); dc->x1-dc->x0+1, dc->y1, dc->color);
goto out; break;
case OSD_FillBlock: case OSD_FillBlock:
DrawBlock(av7110, av7110->osdwin, dc->x0, dc->y0, ret = DrawBlock(av7110, av7110->osdwin, dc->x0, dc->y0,
dc->x1 - dc->x0 + 1, dc->y1 - dc->y0 + 1, dc->color); dc->x1 - dc->x0 + 1, dc->y1 - dc->y0 + 1, dc->color);
goto out; break;
case OSD_Line: case OSD_Line:
DrawLine(av7110, av7110->osdwin, ret = DrawLine(av7110, av7110->osdwin,
dc->x0, dc->y0, dc->x1 - dc->x0, dc->y1 - dc->y0, dc->color); dc->x0, dc->y0, dc->x1 - dc->x0, dc->y1 - dc->y0, dc->color);
goto out; break;
case OSD_Query:
goto out;
case OSD_Test:
goto out;
case OSD_Text: case OSD_Text:
{ {
char textbuf[240]; char textbuf[240];
if (strncpy_from_user(textbuf, dc->data, 240) < 0) { if (strncpy_from_user(textbuf, dc->data, 240) < 0) {
ret = -EFAULT; ret = -EFAULT;
goto out; break;
} }
textbuf[239] = 0; textbuf[239] = 0;
if (dc->x1 > 3) if (dc->x1 > 3)
dc->x1 = 3; dc->x1 = 3;
SetFont(av7110, av7110->osdwin, dc->x1, ret = SetFont(av7110, av7110->osdwin, dc->x1,
(u16) (dc->color & 0xffff), (u16) (dc->color >> 16)); (u16) (dc->color & 0xffff), (u16) (dc->color >> 16));
FlushText(av7110); if (!ret)
WriteText(av7110, av7110->osdwin, dc->x0, dc->y0, textbuf); ret = FlushText(av7110);
goto out; if (!ret)
ret = WriteText(av7110, av7110->osdwin, dc->x0, dc->y0, textbuf);
break;
} }
case OSD_SetWindow: case OSD_SetWindow:
if (dc->x0 < 1 || dc->x0 > 7) { if (dc->x0 < 1 || dc->x0 > 7)
ret = -EINVAL; ret = -EINVAL;
goto out; else {
av7110->osdwin = dc->x0;
ret = 0;
} }
av7110->osdwin = dc->x0; break;
goto out;
case OSD_MoveWindow: case OSD_MoveWindow:
MoveWindowAbs(av7110, av7110->osdwin, dc->x0, dc->y0); ret = MoveWindowAbs(av7110, av7110->osdwin, dc->x0, dc->y0);
SetColorBlend(av7110, av7110->osdwin); if (!ret)
goto out; ret = SetColorBlend(av7110, av7110->osdwin);
break;
case OSD_OpenRaw: case OSD_OpenRaw:
if (dc->color < OSD_BITMAP1 || dc->color > OSD_CURSOR) { if (dc->color < OSD_BITMAP1 || dc->color > OSD_CURSOR) {
ret = -EINVAL; ret = -EINVAL;
goto out; break;
} }
if (dc->color >= OSD_BITMAP1 && dc->color <= OSD_BITMAP8HR) { if (dc->color >= OSD_BITMAP1 && dc->color <= OSD_BITMAP8HR)
av7110->osdbpp[av7110->osdwin] = (1 << (dc->color & 3)) - 1; av7110->osdbpp[av7110->osdwin] = (1 << (dc->color & 3)) - 1;
} else
else {
av7110->osdbpp[av7110->osdwin] = 0; av7110->osdbpp[av7110->osdwin] = 0;
} ret = CreateOSDWindow(av7110, av7110->osdwin, (osd_raw_window_t)dc->color,
CreateOSDWindow(av7110, av7110->osdwin, (osd_raw_window_t)dc->color,
dc->x1 - dc->x0 + 1, dc->y1 - dc->y0 + 1); dc->x1 - dc->x0 + 1, dc->y1 - dc->y0 + 1);
if (ret)
break;
if (!dc->data) { if (!dc->data) {
MoveWindowAbs(av7110, av7110->osdwin, dc->x0, dc->y0); ret = MoveWindowAbs(av7110, av7110->osdwin, dc->x0, dc->y0);
SetColorBlend(av7110, av7110->osdwin); if (!ret)
ret = SetColorBlend(av7110, av7110->osdwin);
} }
goto out; break;
default: default:
ret = -EINVAL; ret = -EINVAL;
goto out; break;
} }
out:
up(&av7110->osd_sema); up(&av7110->osd_sema);
if (ret==-ERESTARTSYS)
dprintk(1, "av7110_osd_cmd(%d) returns with -ERESTARTSYS\n",dc->cmd);
else if (ret)
dprintk(1, "av7110_osd_cmd(%d) returns with %d\n",dc->cmd,ret);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment