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"); ...@@ -54,7 +54,7 @@ MODULE_LICENSE("GPL");
#define DEVICE_DEACTIVATE(x) do { \ #define DEVICE_DEACTIVATE(x) do { \
if ((x) && (x)->capture_device_deactive && \ if ((x) && (x)->capture_device_deactive && \
(x)->capture_device_deactive()) \ (x)->capture_device_deactive()) \
debug_print(KERN_ERR\ debug_print(KERN_ERR \
"capture device %s deactivate failed\n", \ "capture device %s deactivate failed\n", \
(x)->name); \ (x)->name); \
} while (0) } while (0)
...@@ -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,
...@@ -196,7 +202,6 @@ static int buffer_prepare(struct videobuf_queue *q, ...@@ -196,7 +202,6 @@ static int buffer_prepare(struct videobuf_queue *q,
{ {
vpfe_obj *vpfe = &vpfe_device; vpfe_obj *vpfe = &vpfe_device;
if (vb->state == STATE_NEEDS_INIT) { if (vb->state == STATE_NEEDS_INIT) {
vb->width = vpfe->vwin.width; vb->width = vpfe->vwin.width;
vb->height = vpfe->vwin.height; vb->height = vpfe->vwin.height;
...@@ -208,11 +213,13 @@ static int buffer_prepare(struct videobuf_queue *q, ...@@ -208,11 +213,13 @@ static int buffer_prepare(struct videobuf_queue *q,
return 0; return 0;
} }
static void static void
buffer_config(struct videobuf_queue *q, unsigned int count) buffer_config(struct videobuf_queue *q, unsigned int count)
{ {
vpfe_obj *vpfe = &vpfe_device; vpfe_obj *vpfe = &vpfe_device;
int i; int i;
for(i = 0; i < count; i++) { for(i = 0; i < count; i++) {
q->bufs[i]->boff = virt_to_phys(vpfe->fbuffers[i]); q->bufs[i]->boff = virt_to_phys(vpfe->fbuffers[i]);
debug_print(KERN_INFO "buffer address: %x\n", q->bufs[i]->boff); 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) ...@@ -226,7 +233,6 @@ buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
int i; int i;
*size = VPFE_MAX_FBUF_SIZE; *size = VPFE_MAX_FBUF_SIZE;
for (i = VPFE_DEFNUM_FBUFS; i < *count; i++) { for (i = VPFE_DEFNUM_FBUFS; i < *count; i++) {
u32 size = PAGE_SIZE << VPFE_MAX_FBUF_ORDER; u32 size = PAGE_SIZE << VPFE_MAX_FBUF_ORDER;
void *mem = (void *)__get_free_pages(GFP_KERNEL |GFP_DMA, 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) ...@@ -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) static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
{ {
vpfe_obj *vpfe = &vpfe_device; vpfe_obj *vpfe = &vpfe_device;
/* add the buffer to the DMA queue */ /* add the buffer to the DMA queue */
list_add_tail(&vb->queue, &vpfe->dma_queue); list_add_tail(&vb->queue, &vpfe->dma_queue);
vb->state = STATE_QUEUED; vb->state = STATE_QUEUED;
...@@ -270,7 +277,6 @@ static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb) ...@@ -270,7 +277,6 @@ static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
} }
} }
static struct videobuf_queue_ops video_qops = { static struct videobuf_queue_ops video_qops = {
.buf_setup = buffer_setup, .buf_setup = buffer_setup,
.buf_prepare = buffer_prepare, .buf_prepare = buffer_prepare,
...@@ -305,6 +311,7 @@ static int vpfe_select_capture_device(int id) ...@@ -305,6 +311,7 @@ static int vpfe_select_capture_device(int id)
{ {
int err = 0; int err = 0;
struct vpfe_capture_device *device; struct vpfe_capture_device *device;
down_interruptible(&vpfe_device.device_list_lock); down_interruptible(&vpfe_device.device_list_lock);
list_for_each_entry(device, &vpfe_device.capture_device_list, list_for_each_entry(device, &vpfe_device.capture_device_list,
device_list){ device_list){
...@@ -583,38 +590,36 @@ static int vpfe_doioctl(struct inode *inode, struct file *file, ...@@ -583,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:
...@@ -906,12 +911,6 @@ static int vpfe_doioctl(struct inode *inode, struct file *file, ...@@ -906,12 +911,6 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
up(&vpfe->lock); up(&vpfe->lock);
break; break;
} }
case VPFE_CMD_CAPTURE_ACTIVE:
{
int device_id = *((int *)arg);
ret = vpfe_select_capture_device(device_id);
break;
}
default: default:
ret = -ENOIOCTLCMD; ret = -ENOIOCTLCMD;
break; break;
...@@ -962,6 +961,32 @@ static int vpfe_open(struct inode *inode, struct file *filep) ...@@ -962,6 +961,32 @@ static int vpfe_open(struct inode *inode, struct file *filep)
v4l2_prio_open(&vpfe->prio, &fh->prio); v4l2_prio_open(&vpfe->prio, &fh->prio);
vpfe->usrs++; 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; return 0;
} }
...@@ -1106,7 +1131,7 @@ int vpfe_capture_device_unregister(struct vpfe_capture_device *device) ...@@ -1106,7 +1131,7 @@ int vpfe_capture_device_unregister(struct vpfe_capture_device *device)
} }
EXPORT_SYMBOL(vpfe_capture_device_unregister); EXPORT_SYMBOL(vpfe_capture_device_unregister);
static int capture_device_all_unrigister(void) static int capture_device_all_unregister(void)
{ {
int ret = 0; int ret = 0;
struct vpfe_capture_device *device; struct vpfe_capture_device *device;
...@@ -1217,7 +1242,7 @@ static void vpfe_cleanup(void) ...@@ -1217,7 +1242,7 @@ static void vpfe_cleanup(void)
platform_device_unregister(&_vpfe_device); platform_device_unregister(&_vpfe_device);
driver_unregister(&vpfe_driver); driver_unregister(&vpfe_driver);
capture_device_all_unrigister(); capture_device_all_unregister();
/* disable interrupt */ /* disable interrupt */
free_irq(IRQ_VDINT0, &vpfe_device); free_irq(IRQ_VDINT0, &vpfe_device);
......
...@@ -834,28 +834,25 @@ static int tvp5150_get_ctrl(struct i2c_client *c, struct v4l2_control *ctrl) ...@@ -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) 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; fmt &= 0x0F;
switch (fmt) { switch (fmt) {
case 0x00: case 0x01:
*id = V4L2_STD_ALL;
break;
case 0x02:
*id = V4L2_STD_NTSC; *id = V4L2_STD_NTSC;
break; break;
case 0x04: case 0x03:
*id = V4L2_STD_PAL; *id = V4L2_STD_PAL;
break; break;
case 0x06: case 0x05:
*id = V4L2_STD_PAL_M; *id = V4L2_STD_PAL_M;
break; break;
case 0x08: case 0x07:
*id = V4L2_STD_PAL_N | V4L2_STD_PAL_Nc; *id = V4L2_STD_PAL_N | V4L2_STD_PAL_Nc;
break; break;
case 0x0A: case 0x09:
*id = V4L2_STD_NTSC_443; *id = V4L2_STD_NTSC_443;
break; break;
case 0x0C: case 0x0b:
*id = V4L2_STD_SECAM; *id = V4L2_STD_SECAM;
break; break;
default: default:
......
...@@ -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