diff options
author | Dean Anderson <dean@sensoray.com> | 2010-03-04 18:47:33 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-05-17 23:46:35 -0400 |
commit | 3fa0060526eafe3eeda1db681b4aab5b79d4543e (patch) | |
tree | a15658d5032a81c8ccde999cc28dc4ca33fe6433 /drivers/media/video/s2255drv.c | |
parent | 811fab623f435932f2a26aa64b40ec6102618cc6 (diff) |
V4L/DVB: s2255drv: fixes for big endian arch
s2255drv fixes for big endian architecture
Signed-off-by: Dean Anderson <dean@sensoray.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/s2255drv.c')
-rw-r--r-- | drivers/media/video/s2255drv.c | 55 |
1 files changed, 25 insertions, 30 deletions
diff --git a/drivers/media/video/s2255drv.c b/drivers/media/video/s2255drv.c index a9c53335fd8f..882a79679dc6 100644 --- a/drivers/media/video/s2255drv.c +++ b/drivers/media/video/s2255drv.c | |||
@@ -78,11 +78,11 @@ | |||
78 | #define S2255_SETMODE_TIMEOUT 500 | 78 | #define S2255_SETMODE_TIMEOUT 500 |
79 | #define S2255_VIDSTATUS_TIMEOUT 350 | 79 | #define S2255_VIDSTATUS_TIMEOUT 350 |
80 | #define MAX_CHANNELS 4 | 80 | #define MAX_CHANNELS 4 |
81 | #define S2255_MARKER_FRAME 0x2255DA4AL | 81 | #define S2255_MARKER_FRAME cpu_to_le32(0x2255DA4AL) |
82 | #define S2255_MARKER_RESPONSE 0x2255ACACL | 82 | #define S2255_MARKER_RESPONSE cpu_to_le32(0x2255ACACL) |
83 | #define S2255_RESPONSE_SETMODE 0x01 | 83 | #define S2255_RESPONSE_SETMODE cpu_to_le32(0x01) |
84 | #define S2255_RESPONSE_FW 0x10 | 84 | #define S2255_RESPONSE_FW cpu_to_le32(0x10) |
85 | #define S2255_RESPONSE_STATUS 0x20 | 85 | #define S2255_RESPONSE_STATUS cpu_to_le32(0x20) |
86 | #define S2255_USB_XFER_SIZE (16 * 1024) | 86 | #define S2255_USB_XFER_SIZE (16 * 1024) |
87 | #define MAX_CHANNELS 4 | 87 | #define MAX_CHANNELS 4 |
88 | #define MAX_PIPE_BUFFERS 1 | 88 | #define MAX_PIPE_BUFFERS 1 |
@@ -141,12 +141,12 @@ | |||
141 | #define DEF_HUE 0 | 141 | #define DEF_HUE 0 |
142 | 142 | ||
143 | /* usb config commands */ | 143 | /* usb config commands */ |
144 | #define IN_DATA_TOKEN 0x2255c0de | 144 | #define IN_DATA_TOKEN cpu_to_le32(0x2255c0de) |
145 | #define CMD_2255 0xc2255000 | 145 | #define CMD_2255 cpu_to_le32(0xc2255000) |
146 | #define CMD_SET_MODE (CMD_2255 | 0x10) | 146 | #define CMD_SET_MODE cpu_to_le32((CMD_2255 | 0x10)) |
147 | #define CMD_START (CMD_2255 | 0x20) | 147 | #define CMD_START cpu_to_le32((CMD_2255 | 0x20)) |
148 | #define CMD_STOP (CMD_2255 | 0x30) | 148 | #define CMD_STOP cpu_to_le32((CMD_2255 | 0x30)) |
149 | #define CMD_STATUS (CMD_2255 | 0x40) | 149 | #define CMD_STATUS cpu_to_le32((CMD_2255 | 0x40)) |
150 | 150 | ||
151 | struct s2255_mode { | 151 | struct s2255_mode { |
152 | u32 format; /* input video format (NTSC, PAL) */ | 152 | u32 format; /* input video format (NTSC, PAL) */ |
@@ -310,7 +310,7 @@ struct s2255_fh { | |||
310 | /* Need DSP version 5+ for video status feature */ | 310 | /* Need DSP version 5+ for video status feature */ |
311 | #define S2255_MIN_DSP_STATUS 5 | 311 | #define S2255_MIN_DSP_STATUS 5 |
312 | #define S2255_MAJOR_VERSION 1 | 312 | #define S2255_MAJOR_VERSION 1 |
313 | #define S2255_MINOR_VERSION 15 | 313 | #define S2255_MINOR_VERSION 16 |
314 | #define S2255_RELEASE 0 | 314 | #define S2255_RELEASE 0 |
315 | #define S2255_VERSION KERNEL_VERSION(S2255_MAJOR_VERSION, \ | 315 | #define S2255_VERSION KERNEL_VERSION(S2255_MAJOR_VERSION, \ |
316 | S2255_MINOR_VERSION, \ | 316 | S2255_MINOR_VERSION, \ |
@@ -1219,9 +1219,8 @@ static int s2255_set_mode(struct s2255_dev *dev, unsigned long chn, | |||
1219 | struct s2255_mode *mode) | 1219 | struct s2255_mode *mode) |
1220 | { | 1220 | { |
1221 | int res; | 1221 | int res; |
1222 | u32 *buffer; | 1222 | __le32 *buffer; |
1223 | unsigned long chn_rev; | 1223 | unsigned long chn_rev; |
1224 | |||
1225 | mutex_lock(&dev->lock); | 1224 | mutex_lock(&dev->lock); |
1226 | chn_rev = G_chnmap[chn]; | 1225 | chn_rev = G_chnmap[chn]; |
1227 | dprintk(3, "mode scale [%ld] %p %d\n", chn, mode, mode->scale); | 1226 | dprintk(3, "mode scale [%ld] %p %d\n", chn, mode, mode->scale); |
@@ -1247,7 +1246,7 @@ static int s2255_set_mode(struct s2255_dev *dev, unsigned long chn, | |||
1247 | 1246 | ||
1248 | /* set the mode */ | 1247 | /* set the mode */ |
1249 | buffer[0] = IN_DATA_TOKEN; | 1248 | buffer[0] = IN_DATA_TOKEN; |
1250 | buffer[1] = (u32) chn_rev; | 1249 | buffer[1] = (__le32) cpu_to_le32(chn_rev); |
1251 | buffer[2] = CMD_SET_MODE; | 1250 | buffer[2] = CMD_SET_MODE; |
1252 | memcpy(&buffer[3], &dev->mode[chn], sizeof(struct s2255_mode)); | 1251 | memcpy(&buffer[3], &dev->mode[chn], sizeof(struct s2255_mode)); |
1253 | dev->setmode_ready[chn] = 0; | 1252 | dev->setmode_ready[chn] = 0; |
@@ -1278,7 +1277,7 @@ static int s2255_cmd_status(struct s2255_dev *dev, unsigned long chn, | |||
1278 | u32 *pstatus) | 1277 | u32 *pstatus) |
1279 | { | 1278 | { |
1280 | int res; | 1279 | int res; |
1281 | u32 *buffer; | 1280 | __le32 *buffer; |
1282 | u32 chn_rev; | 1281 | u32 chn_rev; |
1283 | mutex_lock(&dev->lock); | 1282 | mutex_lock(&dev->lock); |
1284 | chn_rev = G_chnmap[chn]; | 1283 | chn_rev = G_chnmap[chn]; |
@@ -1291,7 +1290,7 @@ static int s2255_cmd_status(struct s2255_dev *dev, unsigned long chn, | |||
1291 | } | 1290 | } |
1292 | /* form the get vid status command */ | 1291 | /* form the get vid status command */ |
1293 | buffer[0] = IN_DATA_TOKEN; | 1292 | buffer[0] = IN_DATA_TOKEN; |
1294 | buffer[1] = chn_rev; | 1293 | buffer[1] = (__le32) cpu_to_le32(chn_rev); |
1295 | buffer[2] = CMD_STATUS; | 1294 | buffer[2] = CMD_STATUS; |
1296 | *pstatus = 0; | 1295 | *pstatus = 0; |
1297 | dev->vidstatus_ready[chn] = 0; | 1296 | dev->vidstatus_ready[chn] = 0; |
@@ -1971,14 +1970,14 @@ static int save_frame(struct s2255_dev *dev, struct s2255_pipeinfo *pipe_info) | |||
1971 | if (frm->ulState == S2255_READ_IDLE) { | 1970 | if (frm->ulState == S2255_READ_IDLE) { |
1972 | int jj; | 1971 | int jj; |
1973 | unsigned int cc; | 1972 | unsigned int cc; |
1974 | s32 *pdword; | 1973 | __le32 *pdword; /*data from dsp is little endian */ |
1975 | int payload; | 1974 | int payload; |
1976 | /* search for marker codes */ | 1975 | /* search for marker codes */ |
1977 | pdata = (unsigned char *)pipe_info->transfer_buffer; | 1976 | pdata = (unsigned char *)pipe_info->transfer_buffer; |
1977 | pdword = (__le32 *)pdata; | ||
1978 | for (jj = 0; jj < (pipe_info->cur_transfer_size - 12); jj++) { | 1978 | for (jj = 0; jj < (pipe_info->cur_transfer_size - 12); jj++) { |
1979 | switch (*(s32 *) pdata) { | 1979 | switch (*pdword) { |
1980 | case S2255_MARKER_FRAME: | 1980 | case S2255_MARKER_FRAME: |
1981 | pdword = (s32 *)pdata; | ||
1982 | dprintk(4, "found frame marker at offset:" | 1981 | dprintk(4, "found frame marker at offset:" |
1983 | " %d [%x %x]\n", jj, pdata[0], | 1982 | " %d [%x %x]\n", jj, pdata[0], |
1984 | pdata[1]); | 1983 | pdata[1]); |
@@ -2002,7 +2001,6 @@ static int save_frame(struct s2255_dev *dev, struct s2255_pipeinfo *pipe_info) | |||
2002 | dev->jpg_size[dev->cc] = pdword[4]; | 2001 | dev->jpg_size[dev->cc] = pdword[4]; |
2003 | break; | 2002 | break; |
2004 | case S2255_MARKER_RESPONSE: | 2003 | case S2255_MARKER_RESPONSE: |
2005 | pdword = (s32 *)pdata; | ||
2006 | pdata += DEF_USB_BLOCK; | 2004 | pdata += DEF_USB_BLOCK; |
2007 | jj += DEF_USB_BLOCK; | 2005 | jj += DEF_USB_BLOCK; |
2008 | if (pdword[1] >= MAX_CHANNELS) | 2006 | if (pdword[1] >= MAX_CHANNELS) |
@@ -2437,9 +2435,9 @@ static int s2255_start_acquire(struct s2255_dev *dev, unsigned long chn) | |||
2437 | } | 2435 | } |
2438 | 2436 | ||
2439 | /* send the start command */ | 2437 | /* send the start command */ |
2440 | *(u32 *) buffer = IN_DATA_TOKEN; | 2438 | *(__le32 *) buffer = IN_DATA_TOKEN; |
2441 | *((u32 *) buffer + 1) = (u32) chn_rev; | 2439 | *((__le32 *) buffer + 1) = (__le32) cpu_to_le32(chn_rev); |
2442 | *((u32 *) buffer + 2) = (u32) CMD_START; | 2440 | *((__le32 *) buffer + 2) = CMD_START; |
2443 | res = s2255_write_config(dev->udev, (unsigned char *)buffer, 512); | 2441 | res = s2255_write_config(dev->udev, (unsigned char *)buffer, 512); |
2444 | if (res != 0) | 2442 | if (res != 0) |
2445 | dev_err(&dev->udev->dev, "CMD_START error\n"); | 2443 | dev_err(&dev->udev->dev, "CMD_START error\n"); |
@@ -2454,24 +2452,21 @@ static int s2255_stop_acquire(struct s2255_dev *dev, unsigned long chn) | |||
2454 | unsigned char *buffer; | 2452 | unsigned char *buffer; |
2455 | int res; | 2453 | int res; |
2456 | unsigned long chn_rev; | 2454 | unsigned long chn_rev; |
2457 | |||
2458 | if (chn >= MAX_CHANNELS) { | 2455 | if (chn >= MAX_CHANNELS) { |
2459 | dprintk(2, "stop acquire failed, bad channel %lu\n", chn); | 2456 | dprintk(2, "stop acquire failed, bad channel %lu\n", chn); |
2460 | return -1; | 2457 | return -1; |
2461 | } | 2458 | } |
2462 | chn_rev = G_chnmap[chn]; | 2459 | chn_rev = G_chnmap[chn]; |
2463 | |||
2464 | buffer = kzalloc(512, GFP_KERNEL); | 2460 | buffer = kzalloc(512, GFP_KERNEL); |
2465 | if (buffer == NULL) { | 2461 | if (buffer == NULL) { |
2466 | dev_err(&dev->udev->dev, "out of mem\n"); | 2462 | dev_err(&dev->udev->dev, "out of mem\n"); |
2467 | return -ENOMEM; | 2463 | return -ENOMEM; |
2468 | } | 2464 | } |
2469 | |||
2470 | /* send the stop command */ | 2465 | /* send the stop command */ |
2471 | dprintk(4, "stop acquire %lu\n", chn); | 2466 | dprintk(4, "stop acquire %lu\n", chn); |
2472 | *(u32 *) buffer = IN_DATA_TOKEN; | 2467 | *(__le32 *) buffer = IN_DATA_TOKEN; |
2473 | *((u32 *) buffer + 1) = (u32) chn_rev; | 2468 | *((__le32 *) buffer + 1) = (__le32) cpu_to_le32(chn_rev); |
2474 | *((u32 *) buffer + 2) = CMD_STOP; | 2469 | *((__le32 *) buffer + 2) = CMD_STOP; |
2475 | res = s2255_write_config(dev->udev, (unsigned char *)buffer, 512); | 2470 | res = s2255_write_config(dev->udev, (unsigned char *)buffer, 512); |
2476 | 2471 | ||
2477 | if (res != 0) | 2472 | if (res != 0) |