summaryrefslogtreecommitdiff
path: root/linux/drivers/media/dvb/ttpci/av7110_hw.c
diff options
context:
space:
mode:
authorMichael Hunold <devnull@localhost>2004-07-29 19:03:11 +0000
committerMichael Hunold <devnull@localhost>2004-07-29 19:03:11 +0000
commitf1ab4e59f6c372315eeb857324dcbfacee35fcc5 (patch)
treef2453d832b9e89290bc6a8c298a4b5a569f7560a /linux/drivers/media/dvb/ttpci/av7110_hw.c
parent2597e20d12b19a50ebcb3f328cb89a4aabc4366e (diff)
downloadmediapointer-dvb-s2-f1ab4e59f6c372315eeb857324dcbfacee35fcc5.tar.gz
mediapointer-dvb-s2-f1ab4e59f6c372315eeb857324dcbfacee35fcc5.tar.bz2
- timeout variable in arm_thread() must be int, not unsigned long
- replace home-brewn waiting stuff in osd code with wait_event_interruptible_timeout() - put a semaphore around osd calls to make sure they're properly serialized
Diffstat (limited to 'linux/drivers/media/dvb/ttpci/av7110_hw.c')
-rw-r--r--linux/drivers/media/dvb/ttpci/av7110_hw.c138
1 files changed, 73 insertions, 65 deletions
diff --git a/linux/drivers/media/dvb/ttpci/av7110_hw.c b/linux/drivers/media/dvb/ttpci/av7110_hw.c
index d39ec3608..3945fdbde 100644
--- a/linux/drivers/media/dvb/ttpci/av7110_hw.c
+++ b/linux/drivers/media/dvb/ttpci/av7110_hw.c
@@ -742,24 +742,17 @@ static inline int LoadBitmap(struct av7110 *av7110, u16 format,
int i;
int d, delta;
u8 c;
- DECLARE_WAITQUEUE(wait, current);
-
+ int ret;
+
DEB_EE(("av7110: %p\n", av7110));
- if (av7110->bmp_state == BMP_LOADING) {
- add_wait_queue(&av7110->bmpq, &wait);
- while (1) {
- set_current_state(TASK_INTERRUPTIBLE);
- if (av7110->bmp_state != BMP_LOADING
- || signal_pending(current))
- break;
- schedule();
- }
- set_current_state(TASK_RUNNING);
- remove_wait_queue(&av7110->bmpq, &wait);
- }
- if (av7110->bmp_state == BMP_LOADING)
+ ret = wait_event_interruptible_timeout(av7110->bmpq, av7110->bmp_state != BMP_LOADING, HZ);
+ if (ret == -ERESTARTSYS || ret == 0) {
+ printk("dvb-ttpci: warning: timeout waiting in %s()\n", __FUNCTION__);
return -1;
+ }
+ BUG_ON (av7110->bmp_state == BMP_LOADING);
+
av7110->bmp_state = BMP_LOADING;
if (format == OSD_BITMAP8) {
bpp=8; delta = 1;
@@ -801,27 +794,21 @@ static inline int LoadBitmap(struct av7110 *av7110, u16 format,
static int BlitBitmap(struct av7110 *av7110, u16 win, u16 x, u16 y, u16 trans)
{
- DECLARE_WAITQUEUE(wait, current);
+ int ret;
DEB_EE(("av7110: %p\n", av7110));
- if (av7110->bmp_state == BMP_NONE)
+ BUG_ON (av7110->bmp_state == BMP_NONE);
+
+ ret = wait_event_interruptible_timeout(av7110->bmpq, av7110->bmp_state != BMP_LOADING, HZ);
+ if (ret == -ERESTARTSYS || ret == 0) {
+ printk("dvb-ttpci: warning: timeout waiting in %s()\n", __FUNCTION__);
return -1;
- if (av7110->bmp_state == BMP_LOADING) {
- add_wait_queue(&av7110->bmpq, &wait);
- while (1) {
- set_current_state(TASK_INTERRUPTIBLE);
- if (av7110->bmp_state != BMP_LOADING
- || signal_pending(current))
- break;
- schedule();
- }
- set_current_state(TASK_RUNNING);
- remove_wait_queue(&av7110->bmpq, &wait);
}
- if (av7110->bmp_state == BMP_LOADED)
- return av7110_fw_cmd(av7110, COMTYPE_OSD, BlitBmp, 4, win, x, y, trans);
- return -1;
+
+ 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)
@@ -925,10 +912,19 @@ static int OSDSetBlock(struct av7110 *av7110, int x0, int y0,
int av7110_osd_cmd(struct av7110 *av7110, osd_cmd_t *dc)
{
+ int ret;
+
+ ret = down_interruptible(&av7110->osd_sema);
+ if (ret)
+ return -ERESTARTSYS;
+
+ /* stupid, but OSD functions don't provide a return code anyway */
+ ret = 0;
+
switch (dc->cmd) {
case OSD_Close:
DestroyOSDWindow(av7110, av7110->osdwin);
- return 0;
+ goto out;
case OSD_Open:
av7110->osdbpp[av7110->osdwin] = (dc->color - 1) & 7;
CreateOSDWindow(av7110, av7110->osdwin,
@@ -938,27 +934,28 @@ int av7110_osd_cmd(struct av7110 *av7110, osd_cmd_t *dc)
MoveWindowAbs(av7110, av7110->osdwin, dc->x0, dc->y0);
SetColorBlend(av7110, av7110->osdwin);
}
- return 0;
+ goto out;
case OSD_Show:
MoveWindowRel(av7110, av7110->osdwin, 0, 0);
- return 0;
+ goto out;
case OSD_Hide:
HideWindow(av7110, av7110->osdwin);
- return 0;
+ goto out;
case OSD_Clear:
DrawBlock(av7110, av7110->osdwin, 0, 0, 720, 576, 0);
- return 0;
+ goto out;
case OSD_Fill:
DrawBlock(av7110, av7110->osdwin, 0, 0, 720, 576, dc->color);
- return 0;
+ goto out;
case OSD_SetColor:
OSDSetColor(av7110, dc->color, dc->x0, dc->y0, dc->x1, dc->y1);
- return 0;
+ goto out;
case OSD_SetPalette:
{
- if (FW_VERSION(av7110->arm_app) >= 0x2618)
- return OSDSetPalette(av7110, (u32 *)dc->data, dc->color, dc->x0);
- else {
+ if (FW_VERSION(av7110->arm_app) >= 0x2618) {
+ ret = OSDSetPalette(av7110, (u32 *)dc->data, dc->color, dc->x0);
+ goto out;
+ } else {
int i, len = dc->x0-dc->color+1;
u8 *colors = (u8 *)dc->data;
u8 r, g, b, blend;
@@ -967,51 +964,54 @@ int av7110_osd_cmd(struct av7110 *av7110, osd_cmd_t *dc)
if (get_user(r, colors + i * 4) ||
get_user(g, colors + i * 4 + 1) ||
get_user(b, colors + i * 4 + 2) ||
- get_user(blend, colors + i * 4 + 3))
- return -EFAULT;
+ get_user(blend, colors + i * 4 + 3)) {
+ ret = -EFAULT;
+ goto out;
+ }
OSDSetColor(av7110, dc->color + i, r, g, b, blend);
}
}
- return 0;
+ ret = 0;
+ goto out;
}
case OSD_SetTrans:
- return 0;
+ goto out;
case OSD_SetPixel:
DrawLine(av7110, av7110->osdwin,
dc->x0, dc->y0, 0, 0, dc->color);
- return 0;
+ goto out;
case OSD_GetPixel:
- return 0;
-
+ goto out;
case OSD_SetRow:
dc->y1 = dc->y0;
/* fall through */
case OSD_SetBlock:
OSDSetBlock(av7110, dc->x0, dc->y0, dc->x1, dc->y1, dc->color, dc->data);
- return 0;
-
+ goto out;
case OSD_FillRow:
DrawBlock(av7110, av7110->osdwin, dc->x0, dc->y0,
dc->x1-dc->x0+1, dc->y1, dc->color);
- return 0;
+ goto out;
case OSD_FillBlock:
DrawBlock(av7110, av7110->osdwin, dc->x0, dc->y0,
dc->x1 - dc->x0 + 1, dc->y1 - dc->y0 + 1, dc->color);
- return 0;
+ goto out;
case OSD_Line:
DrawLine(av7110, av7110->osdwin,
dc->x0, dc->y0, dc->x1 - dc->x0, dc->y1 - dc->y0, dc->color);
- return 0;
+ goto out;
case OSD_Query:
- return 0;
+ goto out;
case OSD_Test:
- return 0;
+ goto out;
case OSD_Text:
{
char textbuf[240];
- if (strncpy_from_user(textbuf, dc->data, 240) < 0)
- return -EFAULT;
+ if (strncpy_from_user(textbuf, dc->data, 240) < 0) {
+ ret = -EFAULT;
+ goto out;
+ }
textbuf[239] = 0;
if (dc->x1 > 3)
dc->x1 = 3;
@@ -1019,20 +1019,23 @@ int av7110_osd_cmd(struct av7110 *av7110, osd_cmd_t *dc)
(u16) (dc->color & 0xffff), (u16) (dc->color >> 16));
FlushText(av7110);
WriteText(av7110, av7110->osdwin, dc->x0, dc->y0, textbuf);
- return 0;
+ goto out;
}
case OSD_SetWindow:
- if (dc->x0 < 1 || dc->x0 > 7)
- return -EINVAL;
+ if (dc->x0 < 1 || dc->x0 > 7) {
+ ret = -EINVAL;
+ goto out;
+ }
av7110->osdwin = dc->x0;
- return 0;
+ goto out;
case OSD_MoveWindow:
MoveWindowAbs(av7110, av7110->osdwin, dc->x0, dc->y0);
SetColorBlend(av7110, av7110->osdwin);
- return 0;
+ goto out;
case OSD_OpenRaw:
if (dc->color < OSD_BITMAP1 || dc->color > OSD_CURSOR) {
- return -EINVAL;
+ ret = -EINVAL;
+ goto out;
}
if (dc->color >= OSD_BITMAP1 && dc->color <= OSD_BITMAP8HR) {
av7110->osdbpp[av7110->osdwin] = (1 << (dc->color & 3)) - 1;
@@ -1046,10 +1049,15 @@ int av7110_osd_cmd(struct av7110 *av7110, osd_cmd_t *dc)
MoveWindowAbs(av7110, av7110->osdwin, dc->x0, dc->y0);
SetColorBlend(av7110, av7110->osdwin);
}
- return 0;
+ goto out;
default:
- return -EINVAL;
+ ret = -EINVAL;
+ goto out;
}
+
+out:
+ up(&av7110->osd_sema);
+ return ret;
}
int av7110_osd_capability(struct av7110 *av7110, osd_cap_t *cap)