Commit 32d3adcd authored by 薛德章's avatar 薛德章

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 0acae4f3 9523d091
......@@ -12,7 +12,7 @@
LDFLAGS_vmlinux :=-p --no-undefined -X
CPPFLAGS_vmlinux.lds = -DTEXT_OFFSET=$(TEXT_OFFSET)
OBJCOPYFLAGS :=-O binary -R .note -R .comment -S
OBJCOPYFLAGS :=-O binary -R .note -R .note.gnu.build-id -R .comment -S
GZFLAGS :=-9
#CFLAGS +=-pipe
# Explicitly specifiy 32-bit ARM ISA since toolchain default can be -mthumb:
......
......@@ -372,18 +372,10 @@ config VIDEO_VIVI
Say Y here if you want to test video apps or debug V4L devices.
In doubt, say N.
config VIDEO_TVP5146
tristate "TVP5146 video decoder"
depends on I2C && ARCH_DAVINCI
help
Support for I2C bus based TVP5146 configuration.
To compile this driver as a module, choose M here: the
module will be called tvp5146.
config VIDEO_DAVINCI
tristate "Davinci Video Capture"
depends on VIDEO_DEV && VIDEO_TVP5146 && ARCH_DAVINCI
depends on VIDEO_DEV && ARCH_DAVINCI
select VIDEO_BUF
help
Support for Davinci based frame grabber through CCDC.
......@@ -391,6 +383,30 @@ config VIDEO_DAVINCI
To compile this driver as a module, choose M here: the
module will be called vpfe.
choice
prompt "Video Capture Decoder"
optional
depends on VIDEO_DAVINCI
config VIDEO_TVP5146
tristate "TVP5146 video decoder"
depends on I2C && ARCH_DAVINCI
help
Support for I2C bus based TVP5146 configuration.
To compile this driver as a module, choose M here: the
module will be called tvp5146.
config VIDEO_TVP5150
tristate "TVP5150 video decoder"
depends on I2C && ARCH_DAVINCI
help
Support for I2C bus based TVP5150 configuration.
To compile this driver as a module, choose M here: the
module will be called tvp5150.
endchoice
source "drivers/media/video/bt8xx/Kconfig"
config VIDEO_SAA6588
......
......@@ -20,6 +20,7 @@ ifeq ($(CONFIG_VIDEO_V4L1_COMPAT),y)
obj-$(CONFIG_VIDEO_DEV) += v4l1-compat.o
endif
obj-$(CONFIG_VIDEO_DAVINCI) += davinci-vpfe.o
obj-$(CONFIG_VIDEO_BT848) += bt8xx/
obj-$(CONFIG_VIDEO_IR_I2C) += ir-kbd-i2c.o
obj-$(CONFIG_VIDEO_TVAUDIO) += tvaudio.o
......@@ -69,7 +70,6 @@ obj-$(CONFIG_VIDEO_CX88) += cx88/
obj-$(CONFIG_VIDEO_IVTV) += ivtv/
obj-$(CONFIG_VIDEO_EM28XX) += em28xx/
obj-$(CONFIG_VIDEO_USBVISION) += usbvision/
obj-$(CONFIG_VIDEO_TVP5150) += tvp5150.o
obj-$(CONFIG_VIDEO_PVRUSB2) += pvrusb2/
obj-$(CONFIG_VIDEO_MSP3400) += msp3400.o
obj-$(CONFIG_VIDEO_CS53L32A) += cs53l32a.o
......@@ -122,8 +122,8 @@ obj-$(CONFIG_USB_KONICAWC) += usbvideo/
obj-$(CONFIG_USB_VICAM) += usbvideo/
obj-$(CONFIG_USB_QUICKCAM_MESSENGER) += usbvideo/
obj-$(CONFIG_VIDEO_DAVINCI) += davinci-vpfe.o
obj-$(CONFIG_VIDEO_TVP5146) += tvp5146.o
obj-$(CONFIG_VIDEO_TVP5150) += tvp5150.o
obj-$(CONFIG_VIDEO_VIVI) += vivi.o
......
This diff is collapsed.
......@@ -11,6 +11,7 @@
#include <linux/video_decoder.h>
#include <media/v4l2-common.h>
#include <media/tvp5150.h>
#include <asm/arch/gpio.h>
#include "tvp5150_reg.h"
......@@ -45,6 +46,7 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)");
i2c_adapter_id(c->adapter), \
c->addr , ## arg); } while (0)
#define SD_CAP_GPIO GPIO(37)
/* supported controls */
static struct v4l2_queryctrl tvp5150_qctrl[] = {
{
......@@ -98,6 +100,8 @@ struct tvp5150 {
int sat;
};
static struct i2c_client *tvp5150_client;
static int tvp5150_read(struct i2c_client *c, unsigned char addr)
{
unsigned char buffer[1];
......@@ -296,7 +300,7 @@ static inline void tvp5150_selmux(struct i2c_client *c)
switch (decoder->route.input) {
case TVP5150_COMPOSITE1:
input |= 2;
input |= 0;
/* fall through */
case TVP5150_COMPOSITE0:
opmode=0x30; /* TV Mode */
......@@ -828,6 +832,39 @@ static int tvp5150_get_ctrl(struct i2c_client *c, struct v4l2_control *ctrl)
return -EINVAL;
}
static int tvp5150_get_std(struct i2c_client *c, v4l2_std_id *id)
{
int fmt = tvp5150_read(c, TVP5150_VIDEO_STD);
fmt &= 0x0F;
switch (fmt) {
case 0x00:
*id = V4L2_STD_ALL;
break;
case 0x02:
*id = V4L2_STD_NTSC;
break;
case 0x04:
*id = V4L2_STD_PAL;
break;
case 0x06:
*id = V4L2_STD_PAL_M;
break;
case 0x08:
*id = V4L2_STD_PAL_N | V4L2_STD_PAL_Nc;
break;
case 0x0A:
*id = V4L2_STD_NTSC_443;
break;
case 0x0C:
*id = V4L2_STD_SECAM;
break;
default:
*id = V4L2_STD_UNKNOWN;
break;
}
return 0;
}
static int tvp5150_set_ctrl(struct i2c_client *c, struct v4l2_control *ctrl)
{
/* struct tvp5150 *decoder = i2c_get_clientdata(c); */
......@@ -878,6 +915,16 @@ static int tvp5150_command(struct i2c_client *c,
tvp5150_selmux(c);
break;
}
case VIDIOC_S_INPUT:
{
int input = *(int *)arg;
if (input == 0)
decoder->route.input = TVP5150_COMPOSITE1;
else
decoder->route.input = TVP5150_SVIDEO;
tvp5150_selmux(c);
break;
}
case VIDIOC_S_STD:
if (decoder->norm == *(v4l2_std_id *)arg)
break;
......@@ -1021,6 +1068,27 @@ static int tvp5150_command(struct i2c_client *c,
}
return -EINVAL;
}
case VIDIOC_QUERYSTD:
{
v4l2_std_id *id = (v4l2_std_id *)arg;
tvp5150_get_std(c, id);
break;
}
case VPFE_CMD_CONFIG_CAPTURE:
{
struct vpfe_capture_params *params =
(struct vpfe_capture_params *)arg;
if (params->amuxmode == VPFE_AMUX_COMPOSITE) {
decoder->route.input = TVP5150_COMPOSITE1;
} else {
decoder->route.input = TVP5150_SVIDEO;
}
tvp5150_selmux(c);
tvp5150_set_std(c, params->mode);
decoder->norm = params->mode;
break;
}
default:
return -EINVAL;
......@@ -1042,7 +1110,6 @@ static struct i2c_client client_template = {
static int tvp5150_detect_client(struct i2c_adapter *adapter,
int address, int kind)
{
struct i2c_client *c;
struct tvp5150 *core;
int rv;
......@@ -1060,19 +1127,19 @@ static int tvp5150_detect_client(struct i2c_adapter *adapter,
I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE_DATA))
return 0;
c = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
if (c == 0)
tvp5150_client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
if (tvp5150_client == 0)
return -ENOMEM;
memcpy(c, &client_template, sizeof(struct i2c_client));
memcpy(tvp5150_client, &client_template, sizeof(struct i2c_client));
core = kzalloc(sizeof(struct tvp5150), GFP_KERNEL);
if (core == 0) {
kfree(c);
kfree(tvp5150_client);
return -ENOMEM;
}
i2c_set_clientdata(c, core);
i2c_set_clientdata(tvp5150_client, core);
rv = i2c_attach_client(c);
rv = i2c_attach_client(tvp5150_client);
core->norm = V4L2_STD_ALL; /* Default is autodetect */
core->route.input = TVP5150_COMPOSITE1;
......@@ -1083,13 +1150,13 @@ static int tvp5150_detect_client(struct i2c_adapter *adapter,
core->sat = 32768;
if (rv) {
kfree(c);
kfree(tvp5150_client);
kfree(core);
return rv;
}
if (debug > 1)
dump_reg(c);
dump_reg(tvp5150_client);
return 0;
}
......@@ -1122,6 +1189,45 @@ static int tvp5150_detach_client(struct i2c_client *c)
return 0;
}
static inline int tvp5150_device_init(struct vpfe_capture_params *params)
{
return tvp5150_command(tvp5150_client, VIDIOC_INT_RESET, NULL);
}
static inline int tvp5150_device_cmd(u32 cmd, void *arg)
{
return tvp5150_command(tvp5150_client, cmd, arg);
}
static inline void davinci_enable_sdclk(bool on)
{
s8 enable = (on == true ? 0 : 1);
gpio_direction_output(SD_CAP_GPIO, enable);
gpio_set_value(SD_CAP_GPIO, enable);
}
static inline int tvp5150_device_active(void)
{
/* enable the SD_PCLK */
davinci_enable_sdclk(true);
return 0;
}
static inline int tvp5150_device_deactive(void)
{
/* disable the SD_PCLK */
davinci_enable_sdclk(false);
return 0;
}
static inline int tvp5150_device_cleanup(void)
{
/* do nothing */
return 0;
}
/* ----------------------------------------------------------------------- */
static struct i2c_driver driver = {
......@@ -1136,13 +1242,28 @@ static struct i2c_driver driver = {
.command = tvp5150_command,
};
static struct vpfe_capture_device tvp5150_device = {
.name = "TVP5150",
.id = VPFE_CAPTURE_ID_TVP5150,
.capture_device_init = tvp5150_device_init,
.capture_device_cmd = tvp5150_device_cmd,
.capture_device_active = tvp5150_device_active,
.capture_device_deactive = tvp5150_device_deactive,
.capture_device_cleanup = tvp5150_device_cleanup,
};
static int __init tvp5150_init(void)
{
return i2c_add_driver(&driver);
i2c_add_driver(&driver);
return vpfe_capture_device_register(&tvp5150_device);
}
static void __exit tvp5150_exit(void)
{
/* disable the SD_PCLK */
davinci_enable_sdclk(false);
vpfe_capture_device_unregister(&tvp5150_device);
i2c_del_driver(&driver);
}
......
......@@ -24,7 +24,6 @@
#endif
#include <media/ccdc_davinci.h>
#include <media/tvp5146.h>
#define TRUE 1
#define FALSE 0
......@@ -37,7 +36,12 @@
#define VPFE_CMD_CONFIG_CCDC _IOW('V',BASE_VIDIOC_PRIVATE + 1,ccdc_params_ycbcr)
#define VPFE_CMD_LATEST_FRM_ONLY _IOW('V',BASE_VIDIOC_PRIVATE + 2,int)
#define VPFE_CMD_CONFIG_TVP5146 _IOW('V',BASE_VIDIOC_PRIVATE + 3,tvp5146_params)
#define VPFE_CMD_CONFIG_CAPTURE _IOW('V', BASE_VIDIOC_PRIVATE + 3,\
struct vpfe_capture_params)
#define VPFE_CMD_CAPTURE_ACTIVE _IOW('V', BASE_VIDIOC_PRIVATE + 4, long int)
#define VPFE_AMUX_COMPOSITE 0
#define VPFE_AMUX_SVIDEO 1
/* settings for commonly used video formats */
#define VPFE_WIN_NTSC {0,0,720,480}
......@@ -49,6 +53,9 @@
#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
#ifdef __KERNEL__
......@@ -80,6 +87,26 @@
#define VPFE_MAX_FBUF_ORDER \
get_order(roundup_pow_of_two(VPFE_MAX_FBUF_SIZE))
struct vpfe_capture_params{
v4l2_std_id mode;
int amuxmode;
int enablebt656sync;
int squarepixel;
};
struct vpfe_capture_device
{
const char *name;
int id;
struct list_head device_list;
int (*capture_device_init)(struct vpfe_capture_params *param);
int (*capture_device_active)(void);
int (*capture_device_deactive)(void);
int (*capture_device_cmd)(u32 cmd, void *arg);
int (*capture_device_cleanup)(void);
};
/* device object */
typedef struct vpfe_obj {
struct video_device *video_dev;
......@@ -106,7 +133,10 @@ typedef struct vpfe_obj {
int mode_changed;
int started;
int field_offset;
tvp5146_params tvp5146_params;
struct semaphore device_list_lock;
struct vpfe_capture_params capture_params;
struct list_head capture_device_list;
struct vpfe_capture_device *active_device;
ccdc_params_ycbcr ccdc_params;
} vpfe_obj;
......@@ -116,6 +146,24 @@ typedef struct vpfe_fh {
int io_allowed;
enum v4l2_priority prio;
} vpfe_fh;
/**
* register the capture device
* @param device
* device that to be registered.
* @return int
* 0:sucess, otherwise, failed.
*/
int vpfe_capture_device_register(struct vpfe_capture_device *device);
/**
* unregister the capture device
* @param device
* device that to be unregistered.
* @return int
* 0:sucess, otherwise, failed.
*/
int vpfe_capture_device_unregister(struct vpfe_capture_device *device);
#endif
#endif /* DAVINCI_VPFE_H */
......@@ -20,6 +20,8 @@
#ifndef _TVP5150_H_
#define _TVP5150_H_
/* VPFE driver */
#include <media/davinci_vpfe.h>
/* TVP5150 HW inputs */
#define TVP5150_COMPOSITE0 0
......
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