Lines Matching +full:on +full:- +full:the +full:- +full:go

1 // SPDX-License-Identifier: GPL-2.0-only
11 #include <media/v4l2-device.h>
12 #include <media/v4l2-common.h>
13 #include <media/v4l2-subdev.h>
14 #include "go7007-priv.h"
21 * Due to the unusual way these are accessed on this device we do not
22 * reuse the i2c drivers, but instead they are implemented in this
23 * driver. It would be nice to improve on this, though.
130 /* from go7007-usb.c which is Copyright (C) 2005-2006 Micronas USA Inc.*/
131 static int go7007_usb_vendor_request(struct go7007 *go, u16 request, in go7007_usb_vendor_request() argument
134 struct go7007_usb *usb = go->hpi_context; in go7007_usb_vendor_request()
138 return usb_control_msg(usb->usbdev, in go7007_usb_vendor_request()
139 usb_rcvctrlpipe(usb->usbdev, 0), request, in go7007_usb_vendor_request()
143 return usb_control_msg(usb->usbdev, in go7007_usb_vendor_request()
144 usb_sndctrlpipe(usb->usbdev, 0), request, in go7007_usb_vendor_request()
149 /* end from go7007-usb.c which is Copyright (C) 2005-2006 Micronas USA Inc.*/
153 struct go7007 *go = i2c_get_adapdata(client->adapter); in write_reg() local
156 int dev_addr = client->addr << 1; /* firmware wants 8-bit address */ in write_reg()
159 if (go == NULL) in write_reg()
160 return -ENODEV; in write_reg()
162 if (go->status == STATUS_SHUTDOWN) in write_reg()
163 return -EBUSY; in write_reg()
167 return -ENOMEM; in write_reg()
169 usb = go->hpi_context; in write_reg()
170 if (mutex_lock_interruptible(&usb->i2c_lock) != 0) { in write_reg()
171 dev_info(&client->dev, "i2c lock failed\n"); in write_reg()
173 return -EINTR; in write_reg()
175 rc = go7007_usb_vendor_request(go, 0x55, dev_addr, in write_reg()
180 mutex_unlock(&usb->i2c_lock); in write_reg()
187 struct go7007 *go = i2c_get_adapdata(client->adapter); in write_reg_fp() local
193 if (go == NULL) in write_reg_fp()
194 return -ENODEV; in write_reg_fp()
196 if (go->status == STATUS_SHUTDOWN) in write_reg_fp()
197 return -EBUSY; in write_reg_fp()
202 return -ENOMEM; in write_reg_fp()
208 usb = go->hpi_context; in write_reg_fp()
209 if (mutex_lock_interruptible(&usb->i2c_lock) != 0) { in write_reg_fp()
210 dev_info(&client->dev, "i2c lock failed\n"); in write_reg_fp()
212 return -EINTR; in write_reg_fp()
214 rc = go7007_usb_vendor_request(go, 0x57, addr, val, buf, 16, 1); in write_reg_fp()
215 mutex_unlock(&usb->i2c_lock); in write_reg_fp()
228 dev_info(&client->dev, "invalid fp write %x %x\n", in write_reg_fp()
230 return -EFAULT; in write_reg_fp()
233 dev_info(&client->dev, "invalid fp write addr %x %x\n", in write_reg_fp()
235 return -EFAULT; in write_reg_fp()
239 return -EFAULT; in write_reg_fp()
244 dec->reg12b_val = val; in write_reg_fp()
251 struct go7007 *go = i2c_get_adapdata(client->adapter); in read_reg_fp() local
256 if (go == NULL) in read_reg_fp()
257 return -ENODEV; in read_reg_fp()
259 if (go->status == STATUS_SHUTDOWN) in read_reg_fp()
260 return -EBUSY; in read_reg_fp()
265 return -ENOMEM; in read_reg_fp()
270 usb = go->hpi_context; in read_reg_fp()
271 if (mutex_lock_interruptible(&usb->i2c_lock) != 0) { in read_reg_fp()
272 dev_info(&client->dev, "i2c lock failed\n"); in read_reg_fp()
274 return -EINTR; in read_reg_fp()
276 rc = go7007_usb_vendor_request(go, 0x58, addr, 0, buf, 16, 1); in read_reg_fp()
277 mutex_unlock(&usb->i2c_lock); in read_reg_fp()
296 dev_info(&client->dev, "failed\n"); in write_regs()
297 return -1; in write_regs()
309 dev_info(&client->dev, "failed fp\n"); in write_regs_fp()
310 return -1; in write_regs_fp()
317 /* ------------------------------------------------------------------------- */
326 vidsys = (state->std == V4L2_STD_NTSC) ? 0x01 : 0x00; in s2250_s_video_routing()
333 /* S-Video */ in s2250_s_video_routing()
338 return -EINVAL; in s2250_s_video_routing()
340 state->input = input; in s2250_s_video_routing()
350 vidsource = (state->input == 1) ? 0x040 : 0x020; in s2250_s_std()
359 state->std = norm; in s2250_s_std()
365 struct s2250 *state = container_of(ctrl->handler, struct s2250, hdl); in s2250_s_ctrl()
366 struct i2c_client *client = v4l2_get_subdevdata(&state->sd); in s2250_s_ctrl()
369 switch (ctrl->id) { in s2250_s_ctrl()
373 ctrl->val | (oldvalue & ~0xff)); in s2250_s_ctrl()
376 ctrl->val | (oldvalue & ~0xff)); in s2250_s_ctrl()
382 ctrl->val | (oldvalue & ~0x3f)); in s2250_s_ctrl()
385 ctrl->val | (oldvalue & ~0x3f)); in s2250_s_ctrl()
389 write_reg_fp(client, VPX322_ADDR_SAT, ctrl->val); in s2250_s_ctrl()
392 write_reg_fp(client, VPX322_ADDR_HUE, ctrl->val); in s2250_s_ctrl()
395 return -EINVAL; in s2250_s_ctrl()
404 struct v4l2_mbus_framefmt *fmt = &format->format; in s2250_set_fmt()
408 if (format->pad) in s2250_set_fmt()
409 return -EINVAL; in s2250_set_fmt()
411 if (format->which == V4L2_SUBDEV_FORMAT_TRY) in s2250_set_fmt()
414 if (fmt->height < 640) { in s2250_set_fmt()
415 write_reg_fp(client, 0x12b, state->reg12b_val | 0x400); in s2250_set_fmt()
418 write_reg_fp(client, 0x12b, state->reg12b_val & ~0x400); in s2250_set_fmt()
431 write_reg(state->audio, 0x08, 0x02); /* Line In */ in s2250_s_audio_routing()
434 write_reg(state->audio, 0x08, 0x04); /* Mic */ in s2250_s_audio_routing()
437 write_reg(state->audio, 0x08, 0x05); /* Mic Boost */ in s2250_s_audio_routing()
440 return -EINVAL; in s2250_s_audio_routing()
442 state->audio_input = input; in s2250_s_audio_routing()
451 v4l2_info(sd, "Standard: %s\n", state->std == V4L2_STD_NTSC ? "NTSC" : in s2250_log_status()
452 state->std == V4L2_STD_PAL ? "PAL" : in s2250_log_status()
453 state->std == V4L2_STD_SECAM ? "SECAM" : in s2250_log_status()
455 v4l2_info(sd, "Input: %s\n", state->input == 0 ? "Composite" : in s2250_log_status()
456 state->input == 1 ? "S-video" : in s2250_log_status()
458 v4l2_info(sd, "Audio input: %s\n", state->audio_input == 0 ? "Line In" : in s2250_log_status()
459 state->audio_input == 1 ? "Mic" : in s2250_log_status()
460 state->audio_input == 2 ? "Mic Boost" : in s2250_log_status()
465 /* --------------------------------------------------------------------------*/
495 /* --------------------------------------------------------------------------*/
500 struct i2c_adapter *adapter = client->adapter; in s2250_probe()
504 struct go7007 *go = i2c_get_adapdata(adapter); in s2250_probe() local
505 struct go7007_usb *usb = go->hpi_context; in s2250_probe()
506 int err = -EIO; in s2250_probe()
515 return -ENOMEM; in s2250_probe()
518 sd = &state->sd; in s2250_probe()
521 v4l2_info(sd, "initializing %s at address 0x%x on %s\n", in s2250_probe()
522 "Sensoray 2250/2251", client->addr, client->adapter->name); in s2250_probe()
524 v4l2_ctrl_handler_init(&state->hdl, 4); in s2250_probe()
525 v4l2_ctrl_new_std(&state->hdl, &s2250_ctrl_ops, in s2250_probe()
526 V4L2_CID_BRIGHTNESS, -128, 127, 1, 0); in s2250_probe()
527 v4l2_ctrl_new_std(&state->hdl, &s2250_ctrl_ops, in s2250_probe()
529 v4l2_ctrl_new_std(&state->hdl, &s2250_ctrl_ops, in s2250_probe()
531 v4l2_ctrl_new_std(&state->hdl, &s2250_ctrl_ops, in s2250_probe()
532 V4L2_CID_HUE, -512, 511, 1, 0); in s2250_probe()
533 sd->ctrl_handler = &state->hdl; in s2250_probe()
534 if (state->hdl.error) { in s2250_probe()
535 err = state->hdl.error; in s2250_probe()
539 state->std = V4L2_STD_NTSC; in s2250_probe()
540 state->brightness = 50; in s2250_probe()
541 state->contrast = 50; in s2250_probe()
542 state->saturation = 50; in s2250_probe()
543 state->hue = 0; in s2250_probe()
544 state->audio = audio; in s2250_probe()
546 /* initialize the audio */ in s2250_probe()
548 dev_err(&client->dev, "error initializing audio\n"); in s2250_probe()
553 dev_err(&client->dev, "error initializing decoder\n"); in s2250_probe()
557 dev_err(&client->dev, "error initializing decoder\n"); in s2250_probe()
567 state->audio_input = 0; in s2250_probe()
570 if (mutex_lock_interruptible(&usb->i2c_lock) == 0) { in s2250_probe()
573 int rc = go7007_usb_vendor_request(go, 0x41, 0, 0, in s2250_probe()
583 go7007_usb_vendor_request(go, 0x40, 0, in s2250_probe()
590 mutex_unlock(&usb->i2c_lock); in s2250_probe()
598 v4l2_ctrl_handler_free(&state->hdl); in s2250_probe()
607 i2c_unregister_device(state->audio); in s2250_remove()
608 v4l2_device_unregister_subdev(&state->sd); in s2250_remove()
609 v4l2_ctrl_handler_free(&state->hdl); in s2250_remove()