Commit 1a72f1f3 authored by 吴智聪(John Wu)'s avatar 吴智聪(John Wu)

Merge branch 'neuros' of...

Merge branch 'neuros' of ssh://git@git.neuros.com.cn/git/git-pub/osd20/linux-davinci-2.6 into neuros
parents 2e95231c ea459896
......@@ -54,7 +54,7 @@ MODULE_LICENSE("GPL");
#define DEVICE_DEACTIVATE(x) do { \
if ((x) && (x)->capture_device_deactive && \
(x)->capture_device_deactive()) \
debug_print(KERN_ERR\
debug_print(KERN_ERR \
"capture device %s deactivate failed\n", \
(x)->name); \
} while (0)
......@@ -80,8 +80,8 @@ MODULE_LICENSE("GPL");
(x)->name); \
} while (0)
#define DEVICE_CMD(dev, cmd, arg) \
((dev) && (dev)->capture_device_cmd && \
(dev)->capture_device_cmd(cmd, arg));
((dev) && (dev)->capture_device_cmd) ? \
(dev)->capture_device_cmd(cmd, arg) : -EINVAL
static struct v4l2_rect ntsc_bounds = VPFE_WIN_NTSC;
static struct v4l2_rect pal_bounds = VPFE_WIN_PAL;
......@@ -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_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 */
.usrs = 0,
.io_usrs = 0,
......@@ -196,7 +202,6 @@ static int buffer_prepare(struct videobuf_queue *q,
{
vpfe_obj *vpfe = &vpfe_device;
if (vb->state == STATE_NEEDS_INIT) {
vb->width = vpfe->vwin.width;
vb->height = vpfe->vwin.height;
......@@ -208,11 +213,13 @@ static int buffer_prepare(struct videobuf_queue *q,
return 0;
}
static void
buffer_config(struct videobuf_queue *q, unsigned int count)
{
vpfe_obj *vpfe = &vpfe_device;
int i;
for(i = 0; i < count; i++) {
q->bufs[i]->boff = virt_to_phys(vpfe->fbuffers[i]);
debug_print(KERN_INFO "buffer address: %x\n", q->bufs[i]->boff);
......@@ -226,7 +233,6 @@ buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
int i;
*size = VPFE_MAX_FBUF_SIZE;
for (i = VPFE_DEFNUM_FBUFS; i < *count; i++) {
u32 size = PAGE_SIZE << VPFE_MAX_FBUF_ORDER;
void *mem = (void *)__get_free_pages(GFP_KERNEL |GFP_DMA,
......@@ -253,6 +259,7 @@ buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
{
vpfe_obj *vpfe = &vpfe_device;
/* add the buffer to the DMA queue */
list_add_tail(&vb->queue, &vpfe->dma_queue);
vb->state = STATE_QUEUED;
......@@ -270,7 +277,6 @@ static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
}
}
static struct videobuf_queue_ops video_qops = {
.buf_setup = buffer_setup,
.buf_prepare = buffer_prepare,
......@@ -305,6 +311,7 @@ static int vpfe_select_capture_device(int id)
{
int err = 0;
struct vpfe_capture_device *device;
down_interruptible(&vpfe_device.device_list_lock);
list_for_each_entry(device, &vpfe_device.capture_device_list,
device_list){
......@@ -583,38 +590,36 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
}
case VIDIOC_ENUMINPUT:
{
u32 index=0;
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;
index = input->index;
memset(input, 0, sizeof(*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");
}
memcpy(input, &ntosd_inputs[input->index], sizeof(struct v4l2_input));
break;
}
case VIDIOC_G_INPUT:
{
int *index = (int *)arg;
*index = vpfe->capture_params.amuxmode;
break;
}
case VIDIOC_S_INPUT:
{
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;
ret |= DEVICE_CMD(ACTIVE_DEVICE(),
VIDIOC_S_INPUT, index);
ret = DEVICE_CMD(ACTIVE_DEVICE(), VIDIOC_S_INPUT, index);
break;
}
case VIDIOC_CROPCAP:
......@@ -906,12 +911,6 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
up(&vpfe->lock);
break;
}
case VPFE_CMD_CAPTURE_ACTIVE:
{
int device_id = *((int *)arg);
ret = vpfe_select_capture_device(device_id);
break;
}
default:
ret = -ENOIOCTLCMD;
break;
......@@ -962,6 +961,32 @@ static int vpfe_open(struct inode *inode, struct file *filep)
v4l2_prio_open(&vpfe->prio, &fh->prio);
vpfe->usrs++;
/* active the tvp5150 */
vpfe_select_capture_device(VPFE_CAPTURE_ID_TVP5150);
/* detect if there is valid signal input */
{
v4l2_std_id *id;
*id = 0;
down_interruptible(&vpfe->lock);
DEVICE_CMD(ACTIVE_DEVICE(), VIDIOC_QUERYSTD, id);
up(&vpfe->lock);
if (*id != V4L2_STD_UNKNOWN)
vpfe->capture_params.amuxmode = VPFE_AMUX_COMPOSITE;
else
{
/* no valid input for tvp5150 then try tvp7000
* activate the tvp7000, and detect if there is valid input
* Todo after tvp7000 driver available.
*/
debug_print(KERN_INFO "no valid signal input\n");
/* the device can be opened even without valid input
* so if no valid input, use a default one
*/
vpfe->capture_params.amuxmode = VPFE_AMUX_COMPOSITE;
}
}
return 0;
}
......@@ -1106,7 +1131,7 @@ int vpfe_capture_device_unregister(struct vpfe_capture_device *device)
}
EXPORT_SYMBOL(vpfe_capture_device_unregister);
static int capture_device_all_unrigister(void)
static int capture_device_all_unregister(void)
{
int ret = 0;
struct vpfe_capture_device *device;
......@@ -1217,7 +1242,7 @@ static void vpfe_cleanup(void)
platform_device_unregister(&_vpfe_device);
driver_unregister(&vpfe_driver);
capture_device_all_unrigister();
capture_device_all_unregister();
/* disable interrupt */
free_irq(IRQ_VDINT0, &vpfe_device);
......
......@@ -834,28 +834,25 @@ static int tvp5150_get_ctrl(struct i2c_client *c, struct v4l2_control *ctrl)
static int tvp5150_get_std(struct i2c_client *c, v4l2_std_id *id)
{
int fmt = tvp5150_read(c, TVP5150_VIDEO_STD);
int fmt = tvp5150_read(c, TVP5150_STATUS_REG_5);
fmt &= 0x0F;
switch (fmt) {
case 0x00:
*id = V4L2_STD_ALL;
break;
case 0x02:
case 0x01:
*id = V4L2_STD_NTSC;
break;
case 0x04:
case 0x03:
*id = V4L2_STD_PAL;
break;
case 0x06:
case 0x05:
*id = V4L2_STD_PAL_M;
break;
case 0x08:
case 0x07:
*id = V4L2_STD_PAL_N | V4L2_STD_PAL_Nc;
break;
case 0x0A:
case 0x09:
*id = V4L2_STD_NTSC_443;
break;
case 0x0C:
case 0x0b:
*id = V4L2_STD_SECAM;
break;
default:
......
......@@ -41,8 +41,7 @@
#define VPFE_CMD_CAPTURE_ACTIVE _IOW('V', BASE_VIDIOC_PRIVATE + 4, long int)
#define VPFE_AMUX_COMPOSITE 0
#define VPFE_AMUX_SVIDEO 1
#define VPFE_AMUX_COMPONENT 2
#define VPFE_AMUX_COMPONENT 1
/* settings for commonly used video formats */
#define VPFE_WIN_NTSC {0,0,720,480}
......@@ -54,9 +53,8 @@
#define VPFE_WIN_QVGA {0,0,320,240}
#define VPFE_WIN_SIF {0,0,352,240}
#define VPFE_CAPTURE_ID_TVP5146 0
#define VPFE_CAPTURE_ID_TVP5150 1
#define VPFE_CAPTURE_ID_TVP7000 2
#define VPFE_CAPTURE_ID_TVP5150 0
#define VPFE_CAPTURE_ID_TVP7000 1
#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