42 #include <asm/uaccess.h>
44 #include <asm/errno.h>
53 #define GET_STATUS_B00 0x0B00
54 #define SENSOR_TYPE_FORMATTER1 0x0C00
55 #define GET_STATUS_3000 0x3000
56 #define READ_RAW_Y_MEAN_FORMATTER 0x3100
57 #define SET_POWER_SAVE_MODE_FORMATTER 0x3200
58 #define MIRROR_IMAGE_FORMATTER 0x3300
59 #define LED_FORMATTER 0x3400
60 #define LOWLIGHT 0x3500
61 #define GET_STATUS_3600 0x3600
62 #define SENSOR_TYPE_FORMATTER2 0x3700
63 #define GET_STATUS_3800 0x3800
64 #define GET_STATUS_4000 0x4000
65 #define GET_STATUS_4100 0x4100
66 #define CTL_STATUS_4200 0x4200
69 #define VIDEO_OUTPUT_CONTROL_FORMATTER 0x0100
71 static const char *size2name[
PSZ_MAX] =
89 #define PWC_FPS_MAX_NALA 8
98 static unsigned int Nala_fps_vector[
PWC_FPS_MAX_NALA] = { 4, 5, 7, 10, 12, 15, 20, 24 };
107 static int recv_control_msg(
struct pwc_device *pdev,
116 pdev->
ctrl_buf, recv_count, USB_CTRL_GET_TIMEOUT);
118 PWC_ERROR(
"recv_control_msg error %d req %02x val %04x\n",
123 static inline int send_video_command(
struct pwc_device *pdev,
134 pdev->
ctrl_buf, buflen, USB_CTRL_SET_TIMEOUT);
138 PWC_ERROR(
"send_video_command error %d\n", rc);
144 u8 request,
u16 value,
void *buf,
int buflen)
150 buf, buflen, USB_CTRL_SET_TIMEOUT);
153 static int set_video_mode_Nala(
struct pwc_device *pdev,
int size,
int pixfmt,
158 int frames2frames[31] =
168 int frames2table[31] =
178 if (size < 0 || size >
PSZ_CIF)
182 else if (frames > 25)
184 frames = frames2frames[frames];
185 fps = frames2table[frames];
186 pEntry = &Nala_table[
size][fps];
191 ret = send_video_command(pdev, pdev->
vendpoint,
226 static int set_video_mode_Timon(
struct pwc_device *pdev,
int size,
int pixfmt,
227 int frames,
int *compression,
int send_to_cam)
232 if (size >=
PSZ_MAX || *compression < 0 || *compression > 3)
236 else if (size ==
PSZ_VGA && frames > 15)
238 else if (frames > 30)
240 fps = (frames / 5) - 1;
244 while (*compression <= 3) {
254 ret = send_video_command(pdev, pdev->
vendpoint,
277 static int set_video_mode_Kiara(
struct pwc_device *pdev,
int size,
int pixfmt,
278 int frames,
int *compression,
int send_to_cam)
283 if (size >=
PSZ_MAX || *compression < 0 || *compression > 3)
287 else if (size ==
PSZ_VGA && frames > 15)
289 else if (frames > 30)
291 fps = (frames / 5) - 1;
294 while (*compression <= 3) {
305 ret = send_video_command(pdev, 4, pChoose->
mode, 12);
323 PWC_TRACE(
"frame_size=%d, vframes=%d, vsize=%d, vbandlength=%d\n",
329 int pixfmt,
int frames,
int *compression,
int send_to_cam)
334 width, height, frames, pixfmt);
339 ret = set_video_mode_Nala(pdev, size, pixfmt, frames,
340 compression, send_to_cam);
342 ret = set_video_mode_Kiara(pdev, size, pixfmt, frames,
343 compression, send_to_cam);
345 ret = set_video_mode_Timon(pdev, size, pixfmt, frames,
346 compression, send_to_cam);
349 PWC_ERROR(
"Failed to set video mode %s@%d fps; return code = %d\n", size2name[size], frames, ret);
357 static unsigned int pwc_get_fps_Nala(
struct pwc_device *pdev,
unsigned int index,
unsigned int size)
363 if (index--==0)
return Nala_fps_vector[
i];
369 static unsigned int pwc_get_fps_Kiara(
struct pwc_device *pdev,
unsigned int index,
unsigned int size)
381 static unsigned int pwc_get_fps_Timon(
struct pwc_device *pdev,
unsigned int index,
unsigned int size)
398 ret = pwc_get_fps_Nala(pdev, index, size);
401 ret = pwc_get_fps_Kiara(pdev, index, size);
404 ret = pwc_get_fps_Timon(pdev, index, size);
414 ret = recv_control_msg(pdev, request, value, 1);
438 ret = recv_control_msg(pdev, request, value, 1);
450 ret = recv_control_msg(pdev, request, value, 2);
500 PWC_ERROR(
"Failed to power %s camera (%d)\n",
501 power ?
"on" :
"off", r);
508 if (pdev->
type < 730)
518 if (off_value > 0xff)
527 PWC_ERROR(
"Failed to set LED on/off time (%d)\n", r);
532 #ifdef CONFIG_USB_PWC_DEBUG
537 if (pdev->
type < 675)
539 else if (pdev->
type < 730)
547 if (pdev->
type < 675)
548 *sensor = pdev->
ctrl_buf[0] | 0x100;