2019-05-27 06:55:21 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2008-10-30 19:56:41 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2008 Sensoray Company Inc.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/usb.h>
|
|
|
|
#include <linux/i2c.h>
|
|
|
|
#include <linux/videodev2.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2009-11-16 18:13:51 +00:00
|
|
|
#include <media/v4l2-device.h>
|
2008-10-30 19:56:41 +00:00
|
|
|
#include <media/v4l2-common.h>
|
2009-11-16 18:15:07 +00:00
|
|
|
#include <media/v4l2-subdev.h>
|
2008-10-30 19:56:41 +00:00
|
|
|
#include "go7007-priv.h"
|
2009-11-16 18:13:51 +00:00
|
|
|
|
|
|
|
MODULE_DESCRIPTION("Sensoray 2250/2251 i2c v4l2 subdev driver");
|
|
|
|
MODULE_LICENSE("GPL v2");
|
2008-10-30 19:56:41 +00:00
|
|
|
|
2013-03-07 07:58:35 +00:00
|
|
|
/*
|
|
|
|
* Note: this board has two i2c devices: a vpx3226f and a tlv320aic23b.
|
|
|
|
* Due to the unusual way these are accessed on this device we do not
|
|
|
|
* reuse the i2c drivers, but instead they are implemented in this
|
|
|
|
* driver. It would be nice to improve on this, though.
|
|
|
|
*/
|
|
|
|
|
2008-10-30 19:56:41 +00:00
|
|
|
#define TLV320_ADDRESS 0x34
|
|
|
|
#define VPX322_ADDR_ANALOGCONTROL1 0x02
|
|
|
|
#define VPX322_ADDR_BRIGHTNESS0 0x0127
|
|
|
|
#define VPX322_ADDR_BRIGHTNESS1 0x0131
|
|
|
|
#define VPX322_ADDR_CONTRAST0 0x0128
|
|
|
|
#define VPX322_ADDR_CONTRAST1 0x0132
|
|
|
|
#define VPX322_ADDR_HUE 0x00dc
|
2009-09-15 14:06:04 +00:00
|
|
|
#define VPX322_ADDR_SAT 0x0030
|
2008-10-30 19:56:41 +00:00
|
|
|
|
|
|
|
struct go7007_usb_board {
|
|
|
|
unsigned int flags;
|
|
|
|
struct go7007_board_info main_info;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct go7007_usb {
|
|
|
|
struct go7007_usb_board *board;
|
2009-09-15 14:07:59 +00:00
|
|
|
struct mutex i2c_lock;
|
2008-10-30 19:56:41 +00:00
|
|
|
struct usb_device *usbdev;
|
|
|
|
struct urb *video_urbs[8];
|
|
|
|
struct urb *audio_urbs[8];
|
|
|
|
struct urb *intr_urb;
|
|
|
|
};
|
|
|
|
|
|
|
|
static unsigned char aud_regs[] = {
|
|
|
|
0x1e, 0x00,
|
|
|
|
0x00, 0x17,
|
|
|
|
0x02, 0x17,
|
|
|
|
0x04, 0xf9,
|
|
|
|
0x06, 0xf9,
|
|
|
|
0x08, 0x02,
|
|
|
|
0x0a, 0x00,
|
|
|
|
0x0c, 0x00,
|
|
|
|
0x0a, 0x00,
|
|
|
|
0x0c, 0x00,
|
|
|
|
0x0e, 0x02,
|
|
|
|
0x10, 0x00,
|
|
|
|
0x12, 0x01,
|
|
|
|
0x00, 0x00,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static unsigned char vid_regs[] = {
|
|
|
|
0xF2, 0x0f,
|
|
|
|
0xAA, 0x00,
|
|
|
|
0xF8, 0xff,
|
|
|
|
0x00, 0x00,
|
|
|
|
};
|
|
|
|
|
|
|
|
static u16 vid_regs_fp[] = {
|
|
|
|
0x028, 0x067,
|
|
|
|
0x120, 0x016,
|
|
|
|
0x121, 0xcF2,
|
|
|
|
0x122, 0x0F2,
|
|
|
|
0x123, 0x00c,
|
|
|
|
0x124, 0x2d0,
|
|
|
|
0x125, 0x2e0,
|
|
|
|
0x126, 0x004,
|
|
|
|
0x128, 0x1E0,
|
|
|
|
0x12A, 0x016,
|
|
|
|
0x12B, 0x0F2,
|
|
|
|
0x12C, 0x0F2,
|
|
|
|
0x12D, 0x00c,
|
|
|
|
0x12E, 0x2d0,
|
|
|
|
0x12F, 0x2e0,
|
|
|
|
0x130, 0x004,
|
|
|
|
0x132, 0x1E0,
|
|
|
|
0x140, 0x060,
|
|
|
|
0x153, 0x00C,
|
|
|
|
0x154, 0x200,
|
|
|
|
0x150, 0x801,
|
|
|
|
0x000, 0x000
|
|
|
|
};
|
|
|
|
|
|
|
|
/* PAL specific values */
|
2012-11-06 18:40:16 +00:00
|
|
|
static u16 vid_regs_fp_pal[] = {
|
2008-10-30 19:56:41 +00:00
|
|
|
0x120, 0x017,
|
|
|
|
0x121, 0xd22,
|
|
|
|
0x122, 0x122,
|
|
|
|
0x12A, 0x017,
|
|
|
|
0x12B, 0x122,
|
|
|
|
0x12C, 0x122,
|
|
|
|
0x140, 0x060,
|
|
|
|
0x000, 0x000,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct s2250 {
|
2009-11-16 18:15:07 +00:00
|
|
|
struct v4l2_subdev sd;
|
2013-03-03 13:50:34 +00:00
|
|
|
struct v4l2_ctrl_handler hdl;
|
2009-09-19 01:55:13 +00:00
|
|
|
v4l2_std_id std;
|
2008-10-30 19:56:41 +00:00
|
|
|
int input;
|
|
|
|
int brightness;
|
|
|
|
int contrast;
|
|
|
|
int saturation;
|
|
|
|
int hue;
|
|
|
|
int reg12b_val;
|
|
|
|
int audio_input;
|
2009-04-21 19:47:22 +00:00
|
|
|
struct i2c_client *audio;
|
2008-10-30 19:56:41 +00:00
|
|
|
};
|
|
|
|
|
2009-11-16 18:15:07 +00:00
|
|
|
static inline struct s2250 *to_state(struct v4l2_subdev *sd)
|
|
|
|
{
|
|
|
|
return container_of(sd, struct s2250, sd);
|
|
|
|
}
|
|
|
|
|
2008-10-30 19:56:41 +00:00
|
|
|
/* from go7007-usb.c which is Copyright (C) 2005-2006 Micronas USA Inc.*/
|
|
|
|
static int go7007_usb_vendor_request(struct go7007 *go, u16 request,
|
|
|
|
u16 value, u16 index, void *transfer_buffer, int length, int in)
|
|
|
|
{
|
|
|
|
struct go7007_usb *usb = go->hpi_context;
|
|
|
|
int timeout = 5000;
|
|
|
|
|
|
|
|
if (in) {
|
|
|
|
return usb_control_msg(usb->usbdev,
|
|
|
|
usb_rcvctrlpipe(usb->usbdev, 0), request,
|
|
|
|
USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
|
|
|
|
value, index, transfer_buffer, length, timeout);
|
|
|
|
} else {
|
|
|
|
return usb_control_msg(usb->usbdev,
|
|
|
|
usb_sndctrlpipe(usb->usbdev, 0), request,
|
|
|
|
USB_TYPE_VENDOR | USB_RECIP_DEVICE,
|
|
|
|
value, index, transfer_buffer, length, timeout);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* end from go7007-usb.c which is Copyright (C) 2005-2006 Micronas USA Inc.*/
|
|
|
|
|
|
|
|
static int write_reg(struct i2c_client *client, u8 reg, u8 value)
|
|
|
|
{
|
|
|
|
struct go7007 *go = i2c_get_adapdata(client->adapter);
|
2008-12-19 17:11:25 +00:00
|
|
|
struct go7007_usb *usb;
|
2008-10-30 19:56:41 +00:00
|
|
|
int rc;
|
2010-01-13 22:15:48 +00:00
|
|
|
int dev_addr = client->addr << 1; /* firmware wants 8-bit address */
|
2008-10-30 19:56:41 +00:00
|
|
|
u8 *buf;
|
|
|
|
|
|
|
|
if (go == NULL)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
if (go->status == STATUS_SHUTDOWN)
|
|
|
|
return -EBUSY;
|
|
|
|
|
|
|
|
buf = kzalloc(16, GFP_KERNEL);
|
|
|
|
if (buf == NULL)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2008-12-19 17:11:25 +00:00
|
|
|
usb = go->hpi_context;
|
2009-09-15 14:07:59 +00:00
|
|
|
if (mutex_lock_interruptible(&usb->i2c_lock) != 0) {
|
2012-11-06 18:41:03 +00:00
|
|
|
dev_info(&client->dev, "i2c lock failed\n");
|
2008-12-25 20:09:57 +00:00
|
|
|
kfree(buf);
|
2008-10-30 19:56:41 +00:00
|
|
|
return -EINTR;
|
|
|
|
}
|
|
|
|
rc = go7007_usb_vendor_request(go, 0x55, dev_addr,
|
|
|
|
(reg<<8 | value),
|
|
|
|
buf,
|
|
|
|
16, 1);
|
|
|
|
|
2009-09-15 14:07:59 +00:00
|
|
|
mutex_unlock(&usb->i2c_lock);
|
2008-10-30 19:56:41 +00:00
|
|
|
kfree(buf);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int write_reg_fp(struct i2c_client *client, u16 addr, u16 val)
|
|
|
|
{
|
|
|
|
struct go7007 *go = i2c_get_adapdata(client->adapter);
|
2008-12-19 17:11:25 +00:00
|
|
|
struct go7007_usb *usb;
|
2012-02-13 14:01:32 +00:00
|
|
|
int rc;
|
2008-10-30 19:56:41 +00:00
|
|
|
u8 *buf;
|
|
|
|
struct s2250 *dec = i2c_get_clientdata(client);
|
|
|
|
|
|
|
|
if (go == NULL)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
if (go->status == STATUS_SHUTDOWN)
|
|
|
|
return -EBUSY;
|
|
|
|
|
|
|
|
buf = kzalloc(16, GFP_KERNEL);
|
|
|
|
|
|
|
|
if (buf == NULL)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memset(buf, 0xcd, 6);
|
|
|
|
|
2008-12-19 17:11:25 +00:00
|
|
|
usb = go->hpi_context;
|
2009-09-15 14:07:59 +00:00
|
|
|
if (mutex_lock_interruptible(&usb->i2c_lock) != 0) {
|
2012-11-06 18:41:03 +00:00
|
|
|
dev_info(&client->dev, "i2c lock failed\n");
|
2009-09-19 01:05:19 +00:00
|
|
|
kfree(buf);
|
2008-10-30 19:56:41 +00:00
|
|
|
return -EINTR;
|
|
|
|
}
|
2012-02-13 14:01:32 +00:00
|
|
|
rc = go7007_usb_vendor_request(go, 0x57, addr, val, buf, 16, 1);
|
|
|
|
mutex_unlock(&usb->i2c_lock);
|
|
|
|
if (rc < 0) {
|
2009-09-19 01:05:19 +00:00
|
|
|
kfree(buf);
|
2012-02-13 14:01:32 +00:00
|
|
|
return rc;
|
2009-09-19 01:05:19 +00:00
|
|
|
}
|
2008-10-30 19:56:41 +00:00
|
|
|
|
|
|
|
if (buf[0] == 0) {
|
|
|
|
unsigned int subaddr, val_read;
|
|
|
|
|
|
|
|
subaddr = (buf[4] << 8) + buf[5];
|
|
|
|
val_read = (buf[2] << 8) + buf[3];
|
2009-09-19 01:05:19 +00:00
|
|
|
kfree(buf);
|
2008-10-30 19:56:41 +00:00
|
|
|
if (val_read != val) {
|
2012-11-06 18:41:03 +00:00
|
|
|
dev_info(&client->dev, "invalid fp write %x %x\n",
|
|
|
|
val_read, val);
|
2008-10-30 19:56:41 +00:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
if (subaddr != addr) {
|
2012-11-06 18:41:03 +00:00
|
|
|
dev_info(&client->dev, "invalid fp write addr %x %x\n",
|
|
|
|
subaddr, addr);
|
2008-10-30 19:56:41 +00:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
2009-09-19 01:05:19 +00:00
|
|
|
} else {
|
|
|
|
kfree(buf);
|
2008-10-30 19:56:41 +00:00
|
|
|
return -EFAULT;
|
2009-09-19 01:05:19 +00:00
|
|
|
}
|
2008-10-30 19:56:41 +00:00
|
|
|
|
|
|
|
/* save last 12b value */
|
|
|
|
if (addr == 0x12b)
|
|
|
|
dec->reg12b_val = val;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-09-19 01:55:13 +00:00
|
|
|
static int read_reg_fp(struct i2c_client *client, u16 addr, u16 *val)
|
|
|
|
{
|
|
|
|
struct go7007 *go = i2c_get_adapdata(client->adapter);
|
|
|
|
struct go7007_usb *usb;
|
2012-02-13 14:01:32 +00:00
|
|
|
int rc;
|
2009-09-19 01:55:13 +00:00
|
|
|
u8 *buf;
|
|
|
|
|
|
|
|
if (go == NULL)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
if (go->status == STATUS_SHUTDOWN)
|
|
|
|
return -EBUSY;
|
|
|
|
|
|
|
|
buf = kzalloc(16, GFP_KERNEL);
|
|
|
|
|
|
|
|
if (buf == NULL)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memset(buf, 0xcd, 6);
|
|
|
|
usb = go->hpi_context;
|
2009-11-15 11:14:14 +00:00
|
|
|
if (mutex_lock_interruptible(&usb->i2c_lock) != 0) {
|
2012-11-06 18:41:03 +00:00
|
|
|
dev_info(&client->dev, "i2c lock failed\n");
|
2009-09-19 01:55:13 +00:00
|
|
|
kfree(buf);
|
|
|
|
return -EINTR;
|
|
|
|
}
|
2012-02-13 14:01:32 +00:00
|
|
|
rc = go7007_usb_vendor_request(go, 0x58, addr, 0, buf, 16, 1);
|
|
|
|
mutex_unlock(&usb->i2c_lock);
|
|
|
|
if (rc < 0) {
|
2009-09-19 01:55:13 +00:00
|
|
|
kfree(buf);
|
2012-02-13 14:01:32 +00:00
|
|
|
return rc;
|
2009-09-19 01:55:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
*val = (buf[0] << 8) | buf[1];
|
|
|
|
kfree(buf);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-10-30 19:56:41 +00:00
|
|
|
static int write_regs(struct i2c_client *client, u8 *regs)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; !((regs[i] == 0x00) && (regs[i+1] == 0x00)); i += 2) {
|
|
|
|
if (write_reg(client, regs[i], regs[i+1]) < 0) {
|
2012-11-06 18:41:03 +00:00
|
|
|
dev_info(&client->dev, "failed\n");
|
2008-10-30 19:56:41 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int write_regs_fp(struct i2c_client *client, u16 *regs)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; !((regs[i] == 0x00) && (regs[i+1] == 0x00)); i += 2) {
|
|
|
|
if (write_reg_fp(client, regs[i], regs[i+1]) < 0) {
|
2012-11-06 18:41:03 +00:00
|
|
|
dev_info(&client->dev, "failed fp\n");
|
2008-10-30 19:56:41 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-16 18:15:07 +00:00
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static int s2250_s_video_routing(struct v4l2_subdev *sd, u32 input, u32 output,
|
|
|
|
u32 config)
|
2008-10-30 19:56:41 +00:00
|
|
|
{
|
2009-11-16 18:15:07 +00:00
|
|
|
struct s2250 *state = to_state(sd);
|
|
|
|
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
|
|
|
int vidsys;
|
|
|
|
|
|
|
|
vidsys = (state->std == V4L2_STD_NTSC) ? 0x01 : 0x00;
|
|
|
|
if (input == 0) {
|
|
|
|
/* composite */
|
|
|
|
write_reg_fp(client, 0x20, 0x020 | vidsys);
|
|
|
|
write_reg_fp(client, 0x21, 0x662);
|
|
|
|
write_reg_fp(client, 0x140, 0x060);
|
|
|
|
} else if (input == 1) {
|
|
|
|
/* S-Video */
|
|
|
|
write_reg_fp(client, 0x20, 0x040 | vidsys);
|
|
|
|
write_reg_fp(client, 0x21, 0x666);
|
|
|
|
write_reg_fp(client, 0x140, 0x060);
|
|
|
|
} else {
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
state->input = input;
|
|
|
|
return 0;
|
|
|
|
}
|
2008-10-30 19:56:41 +00:00
|
|
|
|
2009-11-16 18:15:07 +00:00
|
|
|
static int s2250_s_std(struct v4l2_subdev *sd, v4l2_std_id norm)
|
|
|
|
{
|
|
|
|
struct s2250 *state = to_state(sd);
|
|
|
|
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
|
|
|
u16 vidsource;
|
|
|
|
|
|
|
|
vidsource = (state->input == 1) ? 0x040 : 0x020;
|
2013-03-11 08:50:21 +00:00
|
|
|
if (norm & V4L2_STD_625_50) {
|
2009-11-16 18:15:07 +00:00
|
|
|
write_regs_fp(client, vid_regs_fp);
|
|
|
|
write_regs_fp(client, vid_regs_fp_pal);
|
|
|
|
write_reg_fp(client, 0x20, vidsource);
|
2013-03-11 08:50:21 +00:00
|
|
|
} else {
|
|
|
|
write_regs_fp(client, vid_regs_fp);
|
|
|
|
write_reg_fp(client, 0x20, vidsource | 1);
|
2008-10-30 19:56:41 +00:00
|
|
|
}
|
2009-11-16 18:15:07 +00:00
|
|
|
state->std = norm;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-03-03 13:50:34 +00:00
|
|
|
static int s2250_s_ctrl(struct v4l2_ctrl *ctrl)
|
2009-11-16 18:15:07 +00:00
|
|
|
{
|
2013-03-03 13:50:34 +00:00
|
|
|
struct s2250 *state = container_of(ctrl->handler, struct s2250, hdl);
|
|
|
|
struct i2c_client *client = v4l2_get_subdevdata(&state->sd);
|
2009-11-16 18:15:07 +00:00
|
|
|
u16 oldvalue;
|
|
|
|
|
|
|
|
switch (ctrl->id) {
|
|
|
|
case V4L2_CID_BRIGHTNESS:
|
|
|
|
read_reg_fp(client, VPX322_ADDR_BRIGHTNESS0, &oldvalue);
|
|
|
|
write_reg_fp(client, VPX322_ADDR_BRIGHTNESS0,
|
2013-03-03 13:50:34 +00:00
|
|
|
ctrl->val | (oldvalue & ~0xff));
|
2009-11-16 18:15:07 +00:00
|
|
|
read_reg_fp(client, VPX322_ADDR_BRIGHTNESS1, &oldvalue);
|
|
|
|
write_reg_fp(client, VPX322_ADDR_BRIGHTNESS1,
|
2013-03-03 13:50:34 +00:00
|
|
|
ctrl->val | (oldvalue & ~0xff));
|
2009-11-16 18:15:07 +00:00
|
|
|
write_reg_fp(client, 0x140, 0x60);
|
2008-10-30 19:56:41 +00:00
|
|
|
break;
|
2009-11-16 18:15:07 +00:00
|
|
|
case V4L2_CID_CONTRAST:
|
|
|
|
read_reg_fp(client, VPX322_ADDR_CONTRAST0, &oldvalue);
|
|
|
|
write_reg_fp(client, VPX322_ADDR_CONTRAST0,
|
2013-03-03 13:50:34 +00:00
|
|
|
ctrl->val | (oldvalue & ~0x3f));
|
2009-11-16 18:15:07 +00:00
|
|
|
read_reg_fp(client, VPX322_ADDR_CONTRAST1, &oldvalue);
|
|
|
|
write_reg_fp(client, VPX322_ADDR_CONTRAST1,
|
2013-03-03 13:50:34 +00:00
|
|
|
ctrl->val | (oldvalue & ~0x3f));
|
2009-11-16 18:15:07 +00:00
|
|
|
write_reg_fp(client, 0x140, 0x60);
|
2008-10-30 19:56:41 +00:00
|
|
|
break;
|
2009-11-16 18:15:07 +00:00
|
|
|
case V4L2_CID_SATURATION:
|
2013-03-03 13:50:34 +00:00
|
|
|
write_reg_fp(client, VPX322_ADDR_SAT, ctrl->val);
|
2009-11-16 18:15:07 +00:00
|
|
|
break;
|
|
|
|
case V4L2_CID_HUE:
|
2013-03-03 13:50:34 +00:00
|
|
|
write_reg_fp(client, VPX322_ADDR_HUE, ctrl->val);
|
2009-11-16 18:15:07 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
2008-10-30 19:56:41 +00:00
|
|
|
}
|
2009-11-16 18:15:07 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-03-21 12:39:09 +00:00
|
|
|
static int s2250_set_fmt(struct v4l2_subdev *sd,
|
media: v4l2-subdev: add subdev-wide state struct
We have 'struct v4l2_subdev_pad_config' which contains configuration for
a single pad used for the TRY functionality, and an array of those
structs is passed to various v4l2_subdev_pad_ops.
I was working on subdev internal routing between pads, and realized that
there's no way to add TRY functionality for routes, which is not pad
specific configuration. Adding a separate struct for try-route config
wouldn't work either, as e.g. set-fmt needs to know the try-route
configuration to propagate the settings.
This patch adds a new struct, 'struct v4l2_subdev_state' (which at the
moment only contains the v4l2_subdev_pad_config array) and the new
struct is used in most of the places where v4l2_subdev_pad_config was
used. All v4l2_subdev_pad_ops functions taking v4l2_subdev_pad_config
are changed to instead take v4l2_subdev_state.
The changes to drivers/media/v4l2-core/v4l2-subdev.c and
include/media/v4l2-subdev.h were written by hand, and all the driver
changes were done with the semantic patch below. The spatch needs to be
applied to a select list of directories. I used the following shell
commands to apply the spatch:
dirs="drivers/media/i2c drivers/media/platform drivers/media/usb drivers/media/test-drivers/vimc drivers/media/pci drivers/staging/media"
for dir in $dirs; do spatch -j8 --dir --include-headers --no-show-diff --in-place --sp-file v4l2-subdev-state.cocci $dir; done
Note that Coccinelle chokes on a few drivers (gcc extensions?). With
minor changes we can make Coccinelle run fine, and these changes can be
reverted after spatch. The diff for these changes is:
For drivers/media/i2c/s5k5baf.c:
@@ -1481,7 +1481,7 @@ static int s5k5baf_set_selection(struct v4l2_subdev *sd,
&s5k5baf_cis_rect,
v4l2_subdev_get_try_crop(sd, cfg, PAD_CIS),
v4l2_subdev_get_try_compose(sd, cfg, PAD_CIS),
- v4l2_subdev_get_try_crop(sd, cfg, PAD_OUT)
+ v4l2_subdev_get_try_crop(sd, cfg, PAD_OUT),
};
s5k5baf_set_rect_and_adjust(rects, rtype, &sel->r);
return 0;
For drivers/media/platform/s3c-camif/camif-capture.c:
@@ -1230,7 +1230,7 @@ static int s3c_camif_subdev_get_fmt(struct v4l2_subdev *sd,
*mf = camif->mbus_fmt;
break;
- case CAMIF_SD_PAD_SOURCE_C...CAMIF_SD_PAD_SOURCE_P:
+ case CAMIF_SD_PAD_SOURCE_C:
/* crop rectangle at camera interface input */
mf->width = camif->camif_crop.width;
mf->height = camif->camif_crop.height;
@@ -1332,7 +1332,7 @@ static int s3c_camif_subdev_set_fmt(struct v4l2_subdev *sd,
}
break;
- case CAMIF_SD_PAD_SOURCE_C...CAMIF_SD_PAD_SOURCE_P:
+ case CAMIF_SD_PAD_SOURCE_C:
/* Pixel format can be only changed on the sink pad. */
mf->code = camif->mbus_fmt.code;
mf->width = crop->width;
The semantic patch is:
// <smpl>
// Change function parameter
@@
identifier func;
identifier cfg;
@@
func(...,
- struct v4l2_subdev_pad_config *cfg
+ struct v4l2_subdev_state *sd_state
, ...)
{
<...
- cfg
+ sd_state
...>
}
// Change function declaration parameter
@@
identifier func;
identifier cfg;
type T;
@@
T func(...,
- struct v4l2_subdev_pad_config *cfg
+ struct v4l2_subdev_state *sd_state
, ...);
// Change function return value
@@
identifier func;
@@
- struct v4l2_subdev_pad_config
+ struct v4l2_subdev_state
*func(...)
{
...
}
// Change function declaration return value
@@
identifier func;
@@
- struct v4l2_subdev_pad_config
+ struct v4l2_subdev_state
*func(...);
// Some drivers pass a local pad_cfg for a single pad to a called function. Wrap it
// inside a pad_state.
@@
identifier func;
identifier pad_cfg;
@@
func(...)
{
...
struct v4l2_subdev_pad_config pad_cfg;
+ struct v4l2_subdev_state pad_state = { .pads = &pad_cfg };
<+...
(
v4l2_subdev_call
|
sensor_call
|
isi_try_fse
|
isc_try_fse
|
saa_call_all
)
(...,
- &pad_cfg
+ &pad_state
,...)
...+>
}
// If the function uses fields from pad_config, access via state->pads
@@
identifier func;
identifier state;
@@
func(...,
struct v4l2_subdev_state *state
, ...)
{
<...
(
- state->try_fmt
+ state->pads->try_fmt
|
- state->try_crop
+ state->pads->try_crop
|
- state->try_compose
+ state->pads->try_compose
)
...>
}
// If the function accesses the filehandle, use fh->state instead
@@
struct v4l2_subdev_fh *fh;
@@
- fh->pad
+ fh->state
@@
struct v4l2_subdev_fh fh;
@@
- fh.pad
+ fh.state
// Start of vsp1 specific
@@
@@
struct vsp1_entity {
...
- struct v4l2_subdev_pad_config *config;
+ struct v4l2_subdev_state *config;
...
};
@@
symbol entity;
@@
vsp1_entity_init(...)
{
...
entity->config =
- v4l2_subdev_alloc_pad_config
+ v4l2_subdev_alloc_state
(&entity->subdev);
...
}
@@
symbol entity;
@@
vsp1_entity_destroy(...)
{
...
- v4l2_subdev_free_pad_config
+ v4l2_subdev_free_state
(entity->config);
...
}
@exists@
identifier func =~ "(^vsp1.*)|(hsit_set_format)|(sru_enum_frame_size)|(sru_set_format)|(uif_get_selection)|(uif_set_selection)|(uds_enum_frame_size)|(uds_set_format)|(brx_set_format)|(brx_get_selection)|(histo_get_selection)|(histo_set_selection)|(brx_set_selection)";
symbol config;
@@
func(...) {
...
- struct v4l2_subdev_pad_config *config;
+ struct v4l2_subdev_state *config;
...
}
// End of vsp1 specific
// Start of rcar specific
@@
identifier sd;
identifier pad_cfg;
@@
rvin_try_format(...)
{
...
- struct v4l2_subdev_pad_config *pad_cfg;
+ struct v4l2_subdev_state *sd_state;
...
- pad_cfg = v4l2_subdev_alloc_pad_config(sd);
+ sd_state = v4l2_subdev_alloc_state(sd);
<...
- pad_cfg
+ sd_state
...>
- v4l2_subdev_free_pad_config(pad_cfg);
+ v4l2_subdev_free_state(sd_state);
...
}
// End of rcar specific
// Start of rockchip specific
@@
identifier func =~ "(rkisp1_rsz_get_pad_fmt)|(rkisp1_rsz_get_pad_crop)|(rkisp1_rsz_register)";
symbol rsz;
symbol pad_cfg;
@@
func(...)
{
+ struct v4l2_subdev_state state = { .pads = rsz->pad_cfg };
...
- rsz->pad_cfg
+ &state
...
}
@@
identifier func =~ "(rkisp1_isp_get_pad_fmt)|(rkisp1_isp_get_pad_crop)";
symbol isp;
symbol pad_cfg;
@@
func(...)
{
+ struct v4l2_subdev_state state = { .pads = isp->pad_cfg };
...
- isp->pad_cfg
+ &state
...
}
@@
symbol rkisp1;
symbol isp;
symbol pad_cfg;
@@
rkisp1_isp_register(...)
{
+ struct v4l2_subdev_state state = { .pads = rkisp1->isp.pad_cfg };
...
- rkisp1->isp.pad_cfg
+ &state
...
}
// End of rockchip specific
// Start of tegra-video specific
@@
identifier sd;
identifier pad_cfg;
@@
__tegra_channel_try_format(...)
{
...
- struct v4l2_subdev_pad_config *pad_cfg;
+ struct v4l2_subdev_state *sd_state;
...
- pad_cfg = v4l2_subdev_alloc_pad_config(sd);
+ sd_state = v4l2_subdev_alloc_state(sd);
<...
- pad_cfg
+ sd_state
...>
- v4l2_subdev_free_pad_config(pad_cfg);
+ v4l2_subdev_free_state(sd_state);
...
}
@@
identifier sd_state;
@@
__tegra_channel_try_format(...)
{
...
struct v4l2_subdev_state *sd_state;
<...
- sd_state->try_crop
+ sd_state->pads->try_crop
...>
}
// End of tegra-video specific
// </smpl>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2021-06-10 14:55:58 +00:00
|
|
|
struct v4l2_subdev_state *sd_state,
|
2015-03-21 12:39:09 +00:00
|
|
|
struct v4l2_subdev_format *format)
|
2009-11-16 18:15:07 +00:00
|
|
|
{
|
2015-03-21 12:39:09 +00:00
|
|
|
struct v4l2_mbus_framefmt *fmt = &format->format;
|
2009-11-16 18:15:07 +00:00
|
|
|
struct s2250 *state = to_state(sd);
|
|
|
|
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
|
|
|
|
2015-03-21 12:39:09 +00:00
|
|
|
if (format->pad)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (format->which == V4L2_SUBDEV_FORMAT_TRY)
|
|
|
|
return 0;
|
|
|
|
|
2010-08-06 19:42:55 +00:00
|
|
|
if (fmt->height < 640) {
|
2009-11-16 18:15:07 +00:00
|
|
|
write_reg_fp(client, 0x12b, state->reg12b_val | 0x400);
|
|
|
|
write_reg_fp(client, 0x140, 0x060);
|
|
|
|
} else {
|
|
|
|
write_reg_fp(client, 0x12b, state->reg12b_val & ~0x400);
|
|
|
|
write_reg_fp(client, 0x140, 0x060);
|
2008-10-30 19:56:41 +00:00
|
|
|
}
|
2009-11-16 18:15:07 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2008-10-30 19:56:41 +00:00
|
|
|
|
2009-11-16 18:15:07 +00:00
|
|
|
static int s2250_s_audio_routing(struct v4l2_subdev *sd, u32 input, u32 output,
|
|
|
|
u32 config)
|
|
|
|
{
|
|
|
|
struct s2250 *state = to_state(sd);
|
|
|
|
|
|
|
|
switch (input) {
|
|
|
|
case 0:
|
|
|
|
write_reg(state->audio, 0x08, 0x02); /* Line In */
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
write_reg(state->audio, 0x08, 0x04); /* Mic */
|
2008-10-30 19:56:41 +00:00
|
|
|
break;
|
2009-11-16 18:15:07 +00:00
|
|
|
case 2:
|
|
|
|
write_reg(state->audio, 0x08, 0x05); /* Mic Boost */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
2008-10-30 19:56:41 +00:00
|
|
|
}
|
2009-11-16 18:15:07 +00:00
|
|
|
state->audio_input = input;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int s2250_log_status(struct v4l2_subdev *sd)
|
|
|
|
{
|
|
|
|
struct s2250 *state = to_state(sd);
|
|
|
|
|
|
|
|
v4l2_info(sd, "Standard: %s\n", state->std == V4L2_STD_NTSC ? "NTSC" :
|
|
|
|
state->std == V4L2_STD_PAL ? "PAL" :
|
|
|
|
state->std == V4L2_STD_SECAM ? "SECAM" :
|
|
|
|
"unknown");
|
|
|
|
v4l2_info(sd, "Input: %s\n", state->input == 0 ? "Composite" :
|
|
|
|
state->input == 1 ? "S-video" :
|
|
|
|
"error");
|
|
|
|
v4l2_info(sd, "Audio input: %s\n", state->audio_input == 0 ? "Line In" :
|
|
|
|
state->audio_input == 1 ? "Mic" :
|
|
|
|
state->audio_input == 2 ? "Mic Boost" :
|
|
|
|
"error");
|
2013-03-03 13:50:34 +00:00
|
|
|
return v4l2_ctrl_subdev_log_status(sd);
|
2008-10-30 19:56:41 +00:00
|
|
|
}
|
|
|
|
|
2009-11-16 18:15:07 +00:00
|
|
|
/* --------------------------------------------------------------------------*/
|
|
|
|
|
2013-03-03 13:50:34 +00:00
|
|
|
static const struct v4l2_ctrl_ops s2250_ctrl_ops = {
|
|
|
|
.s_ctrl = s2250_s_ctrl,
|
|
|
|
};
|
|
|
|
|
2009-11-16 18:15:07 +00:00
|
|
|
static const struct v4l2_subdev_core_ops s2250_core_ops = {
|
|
|
|
.log_status = s2250_log_status,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct v4l2_subdev_audio_ops s2250_audio_ops = {
|
|
|
|
.s_routing = s2250_s_audio_routing,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct v4l2_subdev_video_ops s2250_video_ops = {
|
2014-04-28 19:53:01 +00:00
|
|
|
.s_std = s2250_s_std,
|
2009-11-16 18:15:07 +00:00
|
|
|
.s_routing = s2250_s_video_routing,
|
2015-03-21 12:39:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct v4l2_subdev_pad_ops s2250_pad_ops = {
|
|
|
|
.set_fmt = s2250_set_fmt,
|
2009-11-16 18:15:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct v4l2_subdev_ops s2250_ops = {
|
|
|
|
.core = &s2250_core_ops,
|
|
|
|
.audio = &s2250_audio_ops,
|
|
|
|
.video = &s2250_video_ops,
|
2015-03-21 12:39:09 +00:00
|
|
|
.pad = &s2250_pad_ops,
|
2009-11-16 18:15:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------*/
|
|
|
|
|
2009-04-21 19:47:22 +00:00
|
|
|
static int s2250_probe(struct i2c_client *client,
|
|
|
|
const struct i2c_device_id *id)
|
2008-10-30 19:56:41 +00:00
|
|
|
{
|
2009-04-21 19:47:22 +00:00
|
|
|
struct i2c_client *audio;
|
|
|
|
struct i2c_adapter *adapter = client->adapter;
|
2009-11-16 18:15:07 +00:00
|
|
|
struct s2250 *state;
|
|
|
|
struct v4l2_subdev *sd;
|
2008-10-30 19:56:41 +00:00
|
|
|
u8 *data;
|
|
|
|
struct go7007 *go = i2c_get_adapdata(adapter);
|
|
|
|
struct go7007_usb *usb = go->hpi_context;
|
|
|
|
|
2019-07-22 17:26:02 +00:00
|
|
|
audio = i2c_new_dummy_device(adapter, TLV320_ADDRESS >> 1);
|
|
|
|
if (IS_ERR(audio))
|
|
|
|
return PTR_ERR(audio);
|
2008-10-30 19:56:41 +00:00
|
|
|
|
2013-03-09 12:59:16 +00:00
|
|
|
state = kzalloc(sizeof(struct s2250), GFP_KERNEL);
|
2009-11-16 18:15:07 +00:00
|
|
|
if (state == NULL) {
|
2009-04-21 19:47:22 +00:00
|
|
|
i2c_unregister_device(audio);
|
2008-10-30 19:56:41 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2009-11-16 18:15:07 +00:00
|
|
|
sd = &state->sd;
|
|
|
|
v4l2_i2c_subdev_init(sd, client, &s2250_ops);
|
2008-10-30 19:56:41 +00:00
|
|
|
|
2009-11-16 18:15:07 +00:00
|
|
|
v4l2_info(sd, "initializing %s at address 0x%x on %s\n",
|
|
|
|
"Sensoray 2250/2251", client->addr, client->adapter->name);
|
|
|
|
|
2013-03-03 13:50:34 +00:00
|
|
|
v4l2_ctrl_handler_init(&state->hdl, 4);
|
|
|
|
v4l2_ctrl_new_std(&state->hdl, &s2250_ctrl_ops,
|
|
|
|
V4L2_CID_BRIGHTNESS, -128, 127, 1, 0);
|
|
|
|
v4l2_ctrl_new_std(&state->hdl, &s2250_ctrl_ops,
|
|
|
|
V4L2_CID_CONTRAST, 0, 0x3f, 1, 0x32);
|
|
|
|
v4l2_ctrl_new_std(&state->hdl, &s2250_ctrl_ops,
|
|
|
|
V4L2_CID_SATURATION, 0, 4094, 1, 2070);
|
|
|
|
v4l2_ctrl_new_std(&state->hdl, &s2250_ctrl_ops,
|
|
|
|
V4L2_CID_HUE, -512, 511, 1, 0);
|
|
|
|
sd->ctrl_handler = &state->hdl;
|
|
|
|
if (state->hdl.error) {
|
|
|
|
int err = state->hdl.error;
|
|
|
|
|
|
|
|
v4l2_ctrl_handler_free(&state->hdl);
|
|
|
|
kfree(state);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2009-11-16 18:15:07 +00:00
|
|
|
state->std = V4L2_STD_NTSC;
|
|
|
|
state->brightness = 50;
|
|
|
|
state->contrast = 50;
|
|
|
|
state->saturation = 50;
|
|
|
|
state->hue = 0;
|
|
|
|
state->audio = audio;
|
2008-10-30 19:56:41 +00:00
|
|
|
|
|
|
|
/* initialize the audio */
|
2009-04-21 19:47:22 +00:00
|
|
|
if (write_regs(audio, aud_regs) < 0) {
|
2012-11-06 18:41:03 +00:00
|
|
|
dev_err(&client->dev, "error initializing audio\n");
|
2013-03-03 13:50:34 +00:00
|
|
|
goto fail;
|
2008-10-30 19:56:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (write_regs(client, vid_regs) < 0) {
|
2012-11-06 18:41:03 +00:00
|
|
|
dev_err(&client->dev, "error initializing decoder\n");
|
2013-03-03 13:50:34 +00:00
|
|
|
goto fail;
|
2008-10-30 19:56:41 +00:00
|
|
|
}
|
|
|
|
if (write_regs_fp(client, vid_regs_fp) < 0) {
|
2012-11-06 18:41:03 +00:00
|
|
|
dev_err(&client->dev, "error initializing decoder\n");
|
2013-03-03 13:50:34 +00:00
|
|
|
goto fail;
|
2008-10-30 19:56:41 +00:00
|
|
|
}
|
|
|
|
/* set default channel */
|
|
|
|
/* composite */
|
|
|
|
write_reg_fp(client, 0x20, 0x020 | 1);
|
|
|
|
write_reg_fp(client, 0x21, 0x662);
|
|
|
|
write_reg_fp(client, 0x140, 0x060);
|
|
|
|
|
|
|
|
/* set default audio input */
|
2009-11-16 18:15:07 +00:00
|
|
|
state->audio_input = 0;
|
2008-10-30 19:56:41 +00:00
|
|
|
write_reg(client, 0x08, 0x02); /* Line In */
|
|
|
|
|
2009-09-15 14:07:59 +00:00
|
|
|
if (mutex_lock_interruptible(&usb->i2c_lock) == 0) {
|
2008-10-30 19:56:41 +00:00
|
|
|
data = kzalloc(16, GFP_KERNEL);
|
|
|
|
if (data != NULL) {
|
2014-07-17 23:40:20 +00:00
|
|
|
int rc = go7007_usb_vendor_request(go, 0x41, 0, 0,
|
2008-10-30 19:56:41 +00:00
|
|
|
data, 16, 1);
|
2014-07-17 23:40:20 +00:00
|
|
|
|
2008-10-30 19:56:41 +00:00
|
|
|
if (rc > 0) {
|
|
|
|
u8 mask;
|
2014-07-17 23:40:20 +00:00
|
|
|
|
2008-10-30 19:56:41 +00:00
|
|
|
data[0] = 0;
|
|
|
|
mask = 1<<5;
|
|
|
|
data[0] &= ~mask;
|
|
|
|
data[1] |= mask;
|
|
|
|
go7007_usb_vendor_request(go, 0x40, 0,
|
|
|
|
(data[1]<<8)
|
|
|
|
+ data[1],
|
|
|
|
data, 16, 0);
|
|
|
|
}
|
|
|
|
kfree(data);
|
|
|
|
}
|
2009-09-15 14:07:59 +00:00
|
|
|
mutex_unlock(&usb->i2c_lock);
|
2008-10-30 19:56:41 +00:00
|
|
|
}
|
|
|
|
|
2009-11-16 18:15:07 +00:00
|
|
|
v4l2_info(sd, "initialized successfully\n");
|
2008-10-30 19:56:41 +00:00
|
|
|
return 0;
|
2013-03-03 13:50:34 +00:00
|
|
|
|
|
|
|
fail:
|
|
|
|
i2c_unregister_device(audio);
|
|
|
|
v4l2_ctrl_handler_free(&state->hdl);
|
|
|
|
kfree(state);
|
|
|
|
return -EIO;
|
2008-10-30 19:56:41 +00:00
|
|
|
}
|
|
|
|
|
2009-04-21 19:47:22 +00:00
|
|
|
static int s2250_remove(struct i2c_client *client)
|
2008-10-30 19:56:41 +00:00
|
|
|
{
|
2013-03-03 13:50:34 +00:00
|
|
|
struct s2250 *state = to_state(i2c_get_clientdata(client));
|
2008-10-30 19:56:41 +00:00
|
|
|
|
2019-11-18 11:40:41 +00:00
|
|
|
i2c_unregister_device(state->audio);
|
2013-03-03 13:50:34 +00:00
|
|
|
v4l2_device_unregister_subdev(&state->sd);
|
|
|
|
v4l2_ctrl_handler_free(&state->hdl);
|
|
|
|
kfree(state);
|
2008-10-30 19:56:41 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-01-09 23:18:41 +00:00
|
|
|
static const struct i2c_device_id s2250_id[] = {
|
2009-11-16 18:13:51 +00:00
|
|
|
{ "s2250", 0 },
|
2009-04-21 19:47:22 +00:00
|
|
|
{ }
|
|
|
|
};
|
2009-11-16 18:13:51 +00:00
|
|
|
MODULE_DEVICE_TABLE(i2c, s2250_id);
|
|
|
|
|
2010-09-15 18:53:43 +00:00
|
|
|
static struct i2c_driver s2250_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "s2250",
|
|
|
|
},
|
|
|
|
.probe = s2250_probe,
|
|
|
|
.remove = s2250_remove,
|
|
|
|
.id_table = s2250_id,
|
2008-10-30 19:56:41 +00:00
|
|
|
};
|
2010-09-15 18:53:43 +00:00
|
|
|
|
2012-10-08 11:56:11 +00:00
|
|
|
module_i2c_driver(s2250_driver);
|