提交 ccad7789 编写于 作者: L Luca Risolia 提交者: Greg Kroah-Hartman

[PATCH] USB: ET61X[12]51 driver updates

USB: ET61X[12]51 driver updates

Changes: + new, - removed, * cleanup, @ bugfix

@ Fix stream_interrupt()
@ Fix vidioc_enum_input() and split vidioc_gs_input()
@ Need usb_get|put_dev() when disconnecting, if the device is open
* Use wait_event_interruptible_timeout() instead of wait_event_interruptible()
  when waiting for video frames
* replace wake_up_interruptible(&wait_stream) with wake_up(&wait_stream)
* Cleanups and updates in the documentation
* Use mutexes instead of semaphores
+ Use per-device sensor structures
+ Add support for PAS202BCA image sensors
+ Add frame_timeout module parameter
Signed-off-by: NLuca Risolia <luca.risolia@studio.unibo.it>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 2ffab02f
...@@ -176,6 +176,14 @@ Description: Force the application to unmap previously mapped buffer memory ...@@ -176,6 +176,14 @@ Description: Force the application to unmap previously mapped buffer memory
1 = force memory unmapping (save memory) 1 = force memory unmapping (save memory)
Default: 0 Default: 0
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Name: frame_timeout
Type: uint array (min = 0, max = 64)
Syntax: <n[,...]>
Description: Timeout for a video frame in seconds. This parameter is
specific for each detected camera. This parameter can be
changed at runtime thanks to the /sys filesystem interface.
Default: 2
-------------------------------------------------------------------------------
Name: debug Name: debug
Type: ushort Type: ushort
Syntax: <n> Syntax: <n>
...@@ -266,7 +274,7 @@ the V4L2 interface. ...@@ -266,7 +274,7 @@ the V4L2 interface.
10. Notes for V4L2 application developers 10. Notes for V4L2 application developers
======================================== =========================================
This driver follows the V4L2 API specifications. In particular, it enforces two This driver follows the V4L2 API specifications. In particular, it enforces two
rules: rules:
......
...@@ -33,7 +33,9 @@ ...@@ -33,7 +33,9 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/param.h> #include <linux/param.h>
#include <linux/rwsem.h> #include <linux/rwsem.h>
#include <asm/semaphore.h> #include <linux/mutex.h>
#include <linux/stddef.h>
#include <linux/string.h>
#include "et61x251_sensor.h" #include "et61x251_sensor.h"
...@@ -51,6 +53,7 @@ ...@@ -51,6 +53,7 @@
#define ET61X251_ALTERNATE_SETTING 13 #define ET61X251_ALTERNATE_SETTING 13
#define ET61X251_URB_TIMEOUT msecs_to_jiffies(2 * ET61X251_ISO_PACKETS) #define ET61X251_URB_TIMEOUT msecs_to_jiffies(2 * ET61X251_ISO_PACKETS)
#define ET61X251_CTRL_TIMEOUT 100 #define ET61X251_CTRL_TIMEOUT 100
#define ET61X251_FRAME_TIMEOUT 2
/*****************************************************************************/ /*****************************************************************************/
...@@ -127,15 +130,16 @@ struct et61x251_sysfs_attr { ...@@ -127,15 +130,16 @@ struct et61x251_sysfs_attr {
struct et61x251_module_param { struct et61x251_module_param {
u8 force_munmap; u8 force_munmap;
u16 frame_timeout;
}; };
static DECLARE_MUTEX(et61x251_sysfs_lock); static DEFINE_MUTEX(et61x251_sysfs_lock);
static DECLARE_RWSEM(et61x251_disconnect); static DECLARE_RWSEM(et61x251_disconnect);
struct et61x251_device { struct et61x251_device {
struct video_device* v4ldev; struct video_device* v4ldev;
struct et61x251_sensor* sensor; struct et61x251_sensor sensor;
struct usb_device* usbdev; struct usb_device* usbdev;
struct urb* urb[ET61X251_URBS]; struct urb* urb[ET61X251_URBS];
...@@ -157,19 +161,28 @@ struct et61x251_device { ...@@ -157,19 +161,28 @@ struct et61x251_device {
enum et61x251_dev_state state; enum et61x251_dev_state state;
u8 users; u8 users;
struct semaphore dev_sem, fileop_sem; struct mutex dev_mutex, fileop_mutex;
spinlock_t queue_lock; spinlock_t queue_lock;
wait_queue_head_t open, wait_frame, wait_stream; wait_queue_head_t open, wait_frame, wait_stream;
}; };
/*****************************************************************************/ /*****************************************************************************/
struct et61x251_device*
et61x251_match_id(struct et61x251_device* cam, const struct usb_device_id *id)
{
if (usb_match_id(usb_ifnum_to_if(cam->usbdev, 0), id))
return cam;
return NULL;
}
void void
et61x251_attach_sensor(struct et61x251_device* cam, et61x251_attach_sensor(struct et61x251_device* cam,
struct et61x251_sensor* sensor) struct et61x251_sensor* sensor)
{ {
cam->sensor = sensor; memcpy(&cam->sensor, sensor, sizeof(struct et61x251_sensor));
cam->sensor->usbdev = cam->usbdev;
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -212,7 +225,8 @@ do { \ ...@@ -212,7 +225,8 @@ do { \
#undef PDBG #undef PDBG
#define PDBG(fmt, args...) \ #define PDBG(fmt, args...) \
dev_info(&cam->dev, "[%s:%d] " fmt "\n", __FUNCTION__, __LINE__ , ## args) dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \
__FUNCTION__, __LINE__ , ## args)
#undef PDBGG #undef PDBGG
#define PDBGG(fmt, args...) do {;} while(0) /* placeholder */ #define PDBGG(fmt, args...) do {;} while(0) /* placeholder */
......
此差异已折叠。
...@@ -42,6 +42,9 @@ static int (*et61x251_sensor_table[])(struct et61x251_device*) = { \ ...@@ -42,6 +42,9 @@ static int (*et61x251_sensor_table[])(struct et61x251_device*) = { \
NULL, \ NULL, \
}; };
extern struct et61x251_device*
et61x251_match_id(struct et61x251_device* cam, const struct usb_device_id *id);
extern void extern void
et61x251_attach_sensor(struct et61x251_device* cam, et61x251_attach_sensor(struct et61x251_device* cam,
struct et61x251_sensor* sensor); struct et61x251_sensor* sensor);
...@@ -105,8 +108,6 @@ struct et61x251_sensor { ...@@ -105,8 +108,6 @@ struct et61x251_sensor {
int (*set_pix_format)(struct et61x251_device* cam, int (*set_pix_format)(struct et61x251_device* cam,
const struct v4l2_pix_format* pix); const struct v4l2_pix_format* pix);
const struct usb_device* usbdev;
/* Private */ /* Private */
struct v4l2_queryctrl _qctrl[ET61X251_MAX_CTRLS]; struct v4l2_queryctrl _qctrl[ET61X251_MAX_CTRLS];
struct v4l2_rect _rect; struct v4l2_rect _rect;
......
...@@ -126,12 +126,16 @@ static struct et61x251_sensor tas5130d1b = { ...@@ -126,12 +126,16 @@ static struct et61x251_sensor tas5130d1b = {
int et61x251_probe_tas5130d1b(struct et61x251_device* cam) int et61x251_probe_tas5130d1b(struct et61x251_device* cam)
{ {
/* This sensor has no identifiers, so let's attach it anyway */ const struct usb_device_id tas5130d1b_id_table[] = {
et61x251_attach_sensor(cam, &tas5130d1b); { USB_DEVICE(0x102c, 0x6251), },
{ }
};
/* Sensor detection is based on USB pid/vid */ /* Sensor detection is based on USB pid/vid */
if (le16_to_cpu(tas5130d1b.usbdev->descriptor.idProduct) != 0x6251) if (!et61x251_match_id(cam, tas5130d1b_id_table))
return -ENODEV; return -ENODEV;
et61x251_attach_sensor(cam, &tas5130d1b);
return 0; return 0;
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册