Commit ea459896 authored by 邱宗炽's avatar 邱宗炽

support multi-backend device

fix some ioctls to support multi-backend device
Signed-off-by: default avatar邱宗炽 <tqiu@neuros.com.cn>
parent 4714bf5c
...@@ -80,8 +80,8 @@ MODULE_LICENSE("GPL"); ...@@ -80,8 +80,8 @@ MODULE_LICENSE("GPL");
(x)->name); \ (x)->name); \
} while (0) } while (0)
#define DEVICE_CMD(dev, cmd, arg) \ #define DEVICE_CMD(dev, cmd, arg) \
((dev) && (dev)->capture_device_cmd && \ ((dev) && (dev)->capture_device_cmd) ? \
(dev)->capture_device_cmd(cmd, arg)); (dev)->capture_device_cmd(cmd, arg) : -EINVAL
static struct v4l2_rect ntsc_bounds = VPFE_WIN_NTSC; static struct v4l2_rect ntsc_bounds = VPFE_WIN_NTSC;
static struct v4l2_rect pal_bounds = VPFE_WIN_PAL; static struct v4l2_rect pal_bounds = VPFE_WIN_PAL;
...@@ -91,6 +91,12 @@ static struct v4l2_rect ntscsp_bounds = VPFE_WIN_NTSC_SP; ...@@ -91,6 +91,12 @@ static struct v4l2_rect ntscsp_bounds = VPFE_WIN_NTSC_SP;
static struct v4l2_rect palsp_bounds = VPFE_WIN_PAL_SP; static struct v4l2_rect palsp_bounds = VPFE_WIN_PAL_SP;
static struct v4l2_fract sp_aspect = VPFE_PIXELASPECT_NTSC_SP; static struct v4l2_fract sp_aspect = VPFE_PIXELASPECT_NTSC_SP;
#define NTOSD_INPUTS 2
static struct v4l2_input ntosd_inputs[NTOSD_INPUTS] = {
{ 0, "COMPOSITE", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_ALL, 0 },
{ 1, "COMPONENT", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_ALL, 0 },
};
static vpfe_obj vpfe_device = { /* the default format is NTSC */ static vpfe_obj vpfe_device = { /* the default format is NTSC */
.usrs = 0, .usrs = 0,
.io_usrs = 0, .io_usrs = 0,
...@@ -584,38 +590,36 @@ static int vpfe_doioctl(struct inode *inode, struct file *file, ...@@ -584,38 +590,36 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
} }
case VIDIOC_ENUMINPUT: case VIDIOC_ENUMINPUT:
{ {
u32 index=0;
struct v4l2_input *input = (struct v4l2_input *)arg; struct v4l2_input *input = (struct v4l2_input *)arg;
if (input->index > 1) /* only two inputs are available */
if( input->index < 0 || input->index >= NTOSD_INPUTS)
ret = -EINVAL; ret = -EINVAL;
index = input->index;
memset(input, 0, sizeof(*input)); memcpy(input, &ntosd_inputs[input->index], sizeof(struct v4l2_input));
input->index = index;
input->type = V4L2_INPUT_TYPE_CAMERA;
input->std = V4L2_STD_ALL;
if(input->index == 0){
sprintf(input->name, "COMPOSITE");
}else if(input->index == 1) {
sprintf(input->name, "S-VIDEO");
}
break; break;
} }
case VIDIOC_G_INPUT: case VIDIOC_G_INPUT:
{ {
int *index = (int *)arg; int *index = (int *)arg;
*index = vpfe->capture_params.amuxmode; *index = vpfe->capture_params.amuxmode;
break; break;
} }
case VIDIOC_S_INPUT: case VIDIOC_S_INPUT:
{ {
int *index = (int *)arg; int *index = (int *)arg;
if (*index > 1 || *index < 0) {
ret = -EINVAL; if (*index == VPFE_AMUX_COMPOSITE)
} vpfe_select_capture_device(VPFE_CAPTURE_ID_TVP5150);
else if (*index == VPFE_AMUX_COMPONENT)
vpfe_select_capture_device(VPFE_CAPTURE_ID_TVP7000);
else
return -EINVAL;
vpfe->capture_params.amuxmode = *index; vpfe->capture_params.amuxmode = *index;
ret |= DEVICE_CMD(ACTIVE_DEVICE(), ret = DEVICE_CMD(ACTIVE_DEVICE(), VIDIOC_S_INPUT, index);
VIDIOC_S_INPUT, index);
break; break;
} }
case VIDIOC_CROPCAP: case VIDIOC_CROPCAP:
...@@ -967,7 +971,9 @@ static int vpfe_open(struct inode *inode, struct file *filep) ...@@ -967,7 +971,9 @@ static int vpfe_open(struct inode *inode, struct file *filep)
down_interruptible(&vpfe->lock); down_interruptible(&vpfe->lock);
DEVICE_CMD(ACTIVE_DEVICE(), VIDIOC_QUERYSTD, id); DEVICE_CMD(ACTIVE_DEVICE(), VIDIOC_QUERYSTD, id);
up(&vpfe->lock); up(&vpfe->lock);
if (*id == V4L2_STD_UNKNOWN) if (*id != V4L2_STD_UNKNOWN)
vpfe->capture_params.amuxmode = VPFE_AMUX_COMPOSITE;
else
{ {
/* no valid input for tvp5150 then try tvp7000 /* no valid input for tvp5150 then try tvp7000
* activate the tvp7000, and detect if there is valid input * activate the tvp7000, and detect if there is valid input
......
...@@ -41,8 +41,7 @@ ...@@ -41,8 +41,7 @@
#define VPFE_CMD_CAPTURE_ACTIVE _IOW('V', BASE_VIDIOC_PRIVATE + 4, long int) #define VPFE_CMD_CAPTURE_ACTIVE _IOW('V', BASE_VIDIOC_PRIVATE + 4, long int)
#define VPFE_AMUX_COMPOSITE 0 #define VPFE_AMUX_COMPOSITE 0
#define VPFE_AMUX_SVIDEO 1 #define VPFE_AMUX_COMPONENT 1
#define VPFE_AMUX_COMPONENT 2
/* settings for commonly used video formats */ /* settings for commonly used video formats */
#define VPFE_WIN_NTSC {0,0,720,480} #define VPFE_WIN_NTSC {0,0,720,480}
...@@ -54,9 +53,8 @@ ...@@ -54,9 +53,8 @@
#define VPFE_WIN_QVGA {0,0,320,240} #define VPFE_WIN_QVGA {0,0,320,240}
#define VPFE_WIN_SIF {0,0,352,240} #define VPFE_WIN_SIF {0,0,352,240}
#define VPFE_CAPTURE_ID_TVP5146 0 #define VPFE_CAPTURE_ID_TVP5150 0
#define VPFE_CAPTURE_ID_TVP5150 1 #define VPFE_CAPTURE_ID_TVP7000 1
#define VPFE_CAPTURE_ID_TVP7000 2
#ifdef __KERNEL__ #ifdef __KERNEL__
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment