18 #include <linux/module.h>
21 #include <linux/i2c.h>
22 #include <linux/videodev2.h>
23 #include <linux/slab.h>
32 #define TLV320_ADDRESS 0x34
33 #define VPX322_ADDR_ANALOGCONTROL1 0x02
34 #define VPX322_ADDR_BRIGHTNESS0 0x0127
35 #define VPX322_ADDR_BRIGHTNESS1 0x0131
36 #define VPX322_ADDR_CONTRAST0 0x0128
37 #define VPX322_ADDR_CONTRAST1 0x0132
38 #define VPX322_ADDR_HUE 0x00dc
39 #define VPX322_ADDR_SAT 0x0030
55 static unsigned char aud_regs[] = {
73 static unsigned char vid_regs[] = {
80 static u16 vid_regs_fp[] = {
106 static u16 vid_regs_fp_pal[] =
145 usb_rcvctrlpipe(usb->
usbdev, 0), request,
147 value, index, transfer_buffer, length, timeout);
150 usb_sndctrlpipe(usb->
usbdev, 0), request,
152 value, index, transfer_buffer, length, timeout);
168 if (go->
status == STATUS_SHUTDOWN)
181 rc = go7007_usb_vendor_request(go, 0x55, dev_addr,
197 struct s2250 *dec = i2c_get_clientdata(client);
202 if (go->
status == STATUS_SHUTDOWN)
220 rc = go7007_usb_vendor_request(go, 0x57, addr, val, buf, 16, 1);
228 unsigned int subaddr, val_read;
230 subaddr = (buf[4] << 8) + buf[5];
231 val_read = (buf[2] << 8) + buf[3];
233 if (val_read != val) {
238 if (subaddr != addr) {
265 if (go->
status == STATUS_SHUTDOWN)
282 rc = go7007_usb_vendor_request(go, 0x58, addr, 0, buf, 16, 1);
289 *val = (buf[0] << 8) | buf[1];
300 for (i = 0; !((regs[
i] == 0x00) && (regs[i+1] == 0x00)); i += 2) {
301 if (
write_reg(client, regs[i], regs[i+1]) < 0) {
309 static int write_regs_fp(
struct i2c_client *client,
u16 *regs)
313 for (i = 0; !((regs[
i] == 0x00) && (regs[i+1] == 0x00)); i += 2) {
314 if (write_reg_fp(client, regs[i], regs[i+1]) < 0) {
329 struct i2c_client *client = v4l2_get_subdevdata(sd);
335 write_reg_fp(client, 0x20, 0x020 | vidsys);
336 write_reg_fp(client, 0x21, 0x662);
337 write_reg_fp(client, 0x140, 0x060);
338 }
else if (input == 1) {
340 write_reg_fp(client, 0x20, 0x040 | vidsys);
341 write_reg_fp(client, 0x21, 0x666);
342 write_reg_fp(client, 0x140, 0x060);
352 struct s2250 *state = to_state(sd);
353 struct i2c_client *client = v4l2_get_subdevdata(sd);
356 vidsource = (state->
input == 1) ? 0x040 : 0x020;
359 write_regs_fp(client, vid_regs_fp);
360 write_reg_fp(client, 0x20, vidsource | 1);
363 write_regs_fp(client, vid_regs_fp);
364 write_regs_fp(client, vid_regs_fp_pal);
365 write_reg_fp(client, 0x20, vidsource);
393 struct s2250 *state = to_state(sd);
394 struct i2c_client *client = v4l2_get_subdevdata(sd);
400 if (ctrl->
value > 100)
402 else if (ctrl->
value < 0)
406 value1 = (state->
brightness - 50) * 255 / 100;
409 value1 | (oldvalue & ~0xff));
412 value1 | (oldvalue & ~0xff));
413 write_reg_fp(client, 0x140, 0x60);
416 if (ctrl->
value > 100)
418 else if (ctrl->
value < 0)
422 value1 = state->
contrast * 0x40 / 100;
427 value1 | (oldvalue & ~0x3f));
430 value1 | (oldvalue & ~0x3f));
431 write_reg_fp(client, 0x140, 0x60);
434 if (ctrl->
value > 100)
436 else if (ctrl->
value < 0)
446 if (ctrl->
value > 50)
448 else if (ctrl->
value < -50)
453 value1 = state->
hue * 280 / 50;
464 struct s2250 *state = to_state(sd);
485 static int s2250_s_mbus_fmt(
struct v4l2_subdev *sd,
486 struct v4l2_mbus_framefmt *
fmt)
488 struct s2250 *state = to_state(sd);
489 struct i2c_client *client = v4l2_get_subdevdata(sd);
491 if (fmt->height < 640) {
492 write_reg_fp(client, 0x12b, state->
reg12b_val | 0x400);
493 write_reg_fp(client, 0x140, 0x060);
495 write_reg_fp(client, 0x12b, state->
reg12b_val & ~0x400);
496 write_reg_fp(client, 0x140, 0x060);
504 struct s2250 *state = to_state(sd);
524 static int s2250_log_status(
struct v4l2_subdev *sd)
526 struct s2250 *state = to_state(sd);
533 state->
input == 1 ?
"S-video" :
549 .log_status = s2250_log_status,
550 .g_ctrl = s2250_g_ctrl,
551 .s_ctrl = s2250_s_ctrl,
552 .queryctrl = s2250_queryctrl,
553 .s_std = s2250_s_std,
557 .s_routing = s2250_s_audio_routing,
561 .s_routing = s2250_s_video_routing,
562 .s_mbus_fmt = s2250_s_mbus_fmt,
566 .core = &s2250_core_ops,
567 .audio = &s2250_audio_ops,
568 .video = &s2250_video_ops,
573 static int s2250_probe(
struct i2c_client *client,
581 struct go7007 *go = i2c_get_adapdata(adapter);
597 v4l2_info(sd,
"initializing %s at address 0x%x on %s\n",
598 "Sensoray 2250/2251", client->
addr, client->
adapter->name);
608 if (write_regs(audio, aud_regs) < 0) {
610 "s2250: error initializing audio\n");
616 if (write_regs(client, vid_regs) < 0) {
618 "s2250: error initializing decoder\n");
623 if (write_regs_fp(client, vid_regs_fp) < 0) {
625 "s2250: error initializing decoder\n");
632 write_reg_fp(client, 0x20, 0x020 | 1);
633 write_reg_fp(client, 0x21, 0x662);
634 write_reg_fp(client, 0x140, 0x060);
644 rc = go7007_usb_vendor_request(go, 0x41, 0, 0,
652 go7007_usb_vendor_request(go, 0x40, 0,
662 v4l2_info(sd,
"initialized successfully\n");
666 static int s2250_remove(
struct i2c_client *client)
668 struct v4l2_subdev *sd = i2c_get_clientdata(client);
686 .probe = s2250_probe,
687 .remove = s2250_remove,
688 .id_table = s2250_id,
691 static __init int init_s2250(
void)
693 return i2c_add_driver(&s2250_driver);
696 static __exit void exit_s2250(
void)