Hi ALL!
At this moment, I use DM365EVM (DVSDK4.02) with TVP5150 (instead of TVP5146) for PAL cam.
TVP5150 was placed on a custom daughter card into IMAGER interface (J10).
This is small how to.
Step 1: "drivers/media/video/tvp5150.c"
I made a few changes:
1. The outputs is in tristate mode (disabled) by defaults. You need to enable outputs!!!
Look at 'static inline void tvp5150_selmux()'
----
/* Svideo should enable YCrCb output and disable GPCL output
* For Composite and TV, it should be the reverse
*/
val = tvp5150_read(sd, TVP5150_MISC_CTL);
if (decoder->input == TVP5150_SVIDEO)
val = (val & ~0x40) | 0x10;
else
val = (val & ~0x10) | 0x40;
val = val | 0x08; //!!! My fix. (enable outputs)
tvp5150_write(sd, TVP5150_MISC_CTL, val);
2. You can modify printout of i2c adr at 'tvp5150_probe()' and 'tvp5150_remove()' so driver will print more intelligible i2c adr (eg, '5D' instead of 'BA').
Simple change "c->addr << 1" to "c->addr".
I think that nothing else do not need to touch in this 'tvp5150.c' file!
But, you really have something to edit the file "vpfe-capture.c".
Step 2: "drivers/media/video/davinci/vpfe_capture.c"
1)
static int vpfe_config_ccdc_image_format()
/* At CCDC we need to set pix format based on source. */
if (vpfe_dev->imp_chained) {
if (vpfe_dev->current_subdev->is_camera)
pix_fmt = V4L2_PIX_FMT_SBGGR16;
else if (pix_fmt == V4L2_PIX_FMT_NV12)
pix_fmt = V4L2_PIX_FMT_UYVY;
}
pix_fmt = V4L2_PIX_FMT_UYVY; //!!! My fix!
if (ccdc_dev->hw_ops.set_pixel_format(pix_fmt) < 0) {
v4l2_err(&vpfe_dev->v4l2_dev,
"couldn't set pix format in ccdc\n");
return -EINVAL;
/* configure the image window */
ccdc_dev->hw_ops.set_image_window(&vpfe_dev->crop);
vpfe_dev->fmt.fmt.pix.field=V4L2_FIELD_INTERLACED; //!!! My fix!
switch (vpfe_dev->fmt.fmt.pix.field) {
case V4L2_FIELD_INTERLACED:
2)
static int vpfe_config_image_format()
/* first field and frame format based on standard frame format */
if (vpfe_dev->std_info.frame_format) {
vpfe_dev->fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
/* assume V4L2_PIX_FMT_UYVY as default */
vpfe_dev->fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_UYVY;
} else {
vpfe_dev->fmt.fmt.pix.field = V4L2_FIELD_NONE;
// sd_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
sd_fmt.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE; //!!! My fix!
/* if sub device supports g_fmt, override the defaults */
ret = v4l2_device_call_until_err(&vpfe_dev->v4l2_dev,
Very important! the driver will not work if sd_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE !!!
You need change it to sd_fmt.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE
3)
static int vpfe_s_input()
/* set the default image parameters in the device */
if (vpfe_dev->current_subdev->is_camera) {
vpfe_dev->std_index = -1;
/* for camera, use ccdc default parameters */
ret = vpfe_get_ccdc_image_format(vpfe_dev, &vpfe_dev->fmt);
/* also set the current default format in the sensor */
if (ret)
goto unlock_out;
ret = vpfe_set_format_in_sensor(vpfe_dev, &vpfe_dev->fmt);
//vpfe_dev->std_index = 0; //NTSC
vpfe_dev->std_index = 1; //!!!My fix for PAL
/*
* For non-camera sub device, use standard to configure vpfe
* default
ret = vpfe_config_image_format(vpfe_dev,
&vpfe_standards[vpfe_dev->std_index].std_id);
vpfe_dev->std_index =1; //(my settings for PAL)
see "const struct vpfe_standard vpfe_standards[]" at the top of "vpfe-capture.c" for details.
That's all that I corrected in the file 'vpfe-capture.c'.
Step 3: "include/media/davinci/vpfe_capture.h"
I added the 'tvp5150' device into 'include/media/davinci/vpfe_capture.h'
enum vpfe_subdev_id {
VPFE_SUBDEV_TVP5146 = 1,
VPFE_SUBDEV_MT9T031 = 2,
VPFE_SUBDEV_TVP7002 = 3,
VPFE_SUBDEV_MT9P031 = 4,
VPFE_SUBDEV_TVP5150 = 5, //!!!
};
The next changes are arch specific.
In my case I edited 'arch/arm/mach-davinci/board-dm365-evm.c'
Step 4: "arch/arm/mach-davinci/board-dm365-evm.c"
My TVP5150 is connected to DM365EVM via IMAGER interface, because I needed to make the correct switching of the multiplexer.
Also in this file, I prescribed a "tvp5150_inputs []" and yet something.
#include <media/tvp5150.h>
--- -
#define TVP5150_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
/* Inputs available at the TVP5150 */
static struct v4l2_input tvp5150_inputs[] = {
{
.index = 0,
.name = "Composite",
.type = V4L2_INPUT_TYPE_CAMERA,
.std = TVP5150_STD_ALL,
},
.index = 1,
.name = "Composite1",
static struct vpfe_route tvp5150_routes[] = {
{ //see "include/media/tvp5150.h"
.input = TVP5150_COMPOSITE0,
.output = TVP5150_NORMAL,
static struct vpfe_subdev_info vpfe_sub_devs[] = {
.module_name = "tvp5150",
.grp_id = VPFE_SUBDEV_TVP5150,
.num_inputs = ARRAY_SIZE(tvp5150_inputs),
.inputs = tvp5150_inputs,
.routes = tvp5150_routes,
.can_route = 1,
.ccdc_if_params = {
.if_type = VPFE_BT656,
.hdpol = VPFE_PINPOL_POSITIVE,
.vdpol = VPFE_PINPOL_POSITIVE,
.board_info = {
I2C_BOARD_INFO("tvp5150", 0x5c), // <- place correct i2c adr here!
ALL OTHERS CODECS (tvp5146,tvp7002,ths7353,mt9p031) ARE COMMENTED HERE! = disabled
}; //end of struct vpfe_subdev_info vpfe_sub_devs[]
static int dm365evm_setup_video_input(enum vpfe_subdev_id id)
const char *label;
u8 mux, resets;
mux = __raw_readb(cpld + CPLD_MUX);
mux &= ~CPLD_VIDEO_INPUT_MUX_MASK;
resets = __raw_readb(cpld + CPLD_RESETS);
switch (id) {
case VPFE_SUBDEV_TVP5150:
mux |= CPLD_VIDEO_INPUT_MUX_IMAGER;
label = "tvp5150 SD";
break;
case VPFE_SUBDEV_TVP5146:
mux |= CPLD_VIDEO_INPUT_MUX_TVP5146;
resets &= ~BIT(0);
label = "tvp5146 SD";
dm365evm_reset_imager(0);
That's all for 'board-dm365-evm.c'.
Step 5: Kernel Config (.config)
#
# Video decoders
…
CONFIG_VIDEO_TVP5150=y
Step 6: TEST IT!
SO! I HAVE IT ALL WORKS!
PS: I also got to change on the fly: Brightness, Contrast, Saturation and Hue.
Step 7: $DVSDK/dmai_2_20_00_15/packages/ti/sdo/dmai/linux/dm365/Capture.c
at the end of 'Capture_Handle Capture_create()'
...
hCapture->started = TRUE;
Tvp5150_fd = hCapture->fd; //store file id
return hCapture;
} //end of Capture_Handle Capture_create
at the top of 'Capture.c' file
extern Int Resizer_continuous_delete(int fd);
extern Int Previewer_continuous_delete(int fd);
int Tvp5150_fd=-1;
void Capture_chngTVPCtrl(unsigned char id, unsigned char val) {
if(Tvp5150_fd<0) {
printf("DMAI_Capture: TVP5150Ctl: Tvp5150_fd < 0\n");
return;
struct v4l2_control ctrl;
__s32 vv=val;
case 0:
ctrl.id = V4L2_CID_BRIGHTNESS;
case 1:
ctrl.id = V4L2_CID_CONTRAST;
case 2:
ctrl.id = V4L2_CID_SATURATION;
case 3:
ctrl.id = V4L2_CID_HUE;
vv=(__s32)val-128;
default:
ctrl.value = vv;
if (-1 == ioctl (Tvp5150_fd, VIDIOC_S_CTRL, &ctrl)) {
printf("DMAI_Capture: TVP5150Ctl: VIDIOC_S_CTRL failed!\n");
/******************************************************************************
* cleanup
******************************************************************************/
static Int cleanup(Capture_Handle hCapture)
Step 8: Change brightness and so on from DVSDK-DEMO (encode) EXAMPLE.
$DVSDK/dvsdk-demos_4_02_00_01/dm365/ctrl.c
------
#include <ti/sdo/dmai/Capture.h>
// Try other values!
unsigned char brt=128; //brightness 0..255
unsigned char con=128; //contrast 0..255
unsigned char sat=128; //saturation 0..255
unsigned char hue=128; //HUE 0..255
Capture_chngTVPCtrl(0,brt); //set brightness
Capture_chngTVPCtrl(1,con); //set contrast
Capture_chngTVPCtrl(2,sat); //set saturation
Capture_chngTVPCtrl(3,hue); //set hue
IT WORKS! :-)
Good luck!
Hi, senchuss
Thanks for your tvp5150 for dm365 guide!
I use your steps to moidfy the vpfe and tvp5150 driver , and then run dvsdk's encode demo, the driver output "tvp5150 1-005d: VBI can't be configured without knowing number of lines" messages, and cann't capture video. Is there missing steps?
I add a "printk" in vpfe_isr function, when run encode demo i can see the printk's output. Dose this means than tvp5150 work OK ?
Dear Sir,
This howto has some proble.
I use tvp5150 and dvsdk4 and use dvsdk-demos encode to test, but it can't capture ok.
If I use :(PAL signal input)
encode -v x.264 -I 1 -y 2 -w
(This will VIDENC1_process ret -1)
encode -v x.264 -I 1 -y 2 -w -r 704x576
This will not receive isr, can't capture ok.
I check tvp5150's reg and this howto so many times.
But I can't capture ok.
Please help me. Thanks.
Hi,
In the encode demo i can see that capture is set as ColorSpace_YUV420PSEMI (NV12), I think it is possible to set the capture as NV12 (YUV420) to meet the codec input requirement.
I can see that DMAI & V4L2 layer supports NV12 configuration for capture. I am not familiar with the TVP51xx parts, but as the software layer has this supports someone underneath must do conversion if TVP51xx part can not get NV12 format.
Best Regards
Velan
Don't forget to verify answers to your forum questions by using the green "verify Answer" button.
Did you read the DVSDK4.x FAQ? If not, PLEASE read it.
Can i please ask what are you doing with the Y inputs of the DM365 ?TVP5150 uses bt656 8bit mode and they are connected to the DM365 C inputs,But what must i do with the DM365 Y inputs ?? Can I use them as GPIO ??What did you do with your DM365 Y input ??
Any answer will be highly appriciated Thanks Amir
Thanks for this info, it was really useful. It helps me to create alternative firmware for DVS-310-1 (Appro oem video server).
Also I noticed, that input video (from VPFE capture) must be forced to resizer, even if I don't need resizing, that's due Gstreamer's H264 encoder wants only NV12 format, but VPFE returns only UYVY or YUYV formats.
we do the steps and the demo can run ,but no data return from dqbuf, the isr in vpfe_capture not called,
we have been delaed by this issue for month now, anyone have solved this problem please share.
and by the way, we connect the 5150 output to C0-7 of vpfe, is that correct????
We have a similar problem. That's why i can't tell you the right solution of the problem. Two things i can advise:
1. Check if YCINSWP bit is NOT set in CCDCFG register (you can find it a dm365_ccdc.c). This because you're using C0-7 inputs on your davinci.
2. Check the PCLK output from decoder (tvp5150). I think that clock must present. If not, add "val |= 0x09;" instead of "val = val | 0x08;" in the decoder driver tvp5150.c , function tvp5150_selmux()
Let me know if something of this helps you.
Good luck.
Hi ALL.I apologize if some people have problems. In my case all was fine with dm365evm (tvp5150 via imager connector).May be you need to check your hardware connections?Carefully check 'board-dm365-evm.c' and especially Altera MUX if you use imager interface for tvp5150. Check clocks and so on.Now, I have my custom board with TVP5150 routed directly to DM365 (YIN0..YIN7, HSYNC,VSYNC,PCLK). It works fine!to Osery Huang,Try to use YIN0..YIN7 inputs!Here is a patch based on first half of topic post -> 0743.TVP5150_without_BRDsupport.patch.zip
The second task is to modify 'arch/arm/mach-davinci/board-dm365-evm.c' for your custom hardware design.I can't post my custom 'board-dm365-evm.c' because it has many modifications that not related to tvp5150. But it really based on topic post (tvp5150_routes[], vpfe_sub_devs[]). In my case I remove all things related to altera mux because my tvp5150 connected directly to YIN-port now. In my case all works fine.
hi senchuss i do all the patch.
on the boot kernel the tvp 5150 is detected and registered .
the encoder cannot get lines and standard
on the board i have connected the tvp7002 and all work ok.
on the same bus i have sw for connect the tvp5150 / tvp7002.(not the same add).
the boot :
i2c /dev entries driverLinux video capture interface: v2.00vpfe_initvpfe-capture: vpss clock vpss_master enabledvpfe-capture vpfe-capture: v4l2 device registeredvpfe-capture vpfe-capture: video device registeredEVM: switch to tvp5150 SD video inputtvp5150 1-00ba: chip found @ 0x174 (DaVinci I2C adapter)vpfe-capture vpfe-capture: v4l2 sub device tvp5150 registeredEVM: switch to tvp7002 HD video inputfrom tvp7002 tvp7002_initializetvp7002 1-005c: get id std =0 std 0x4000000000000tvp7002 1-005c: tvp7002 1-005c decoder driver registered !!vpfe-capture vpfe-capture: v4l2 sub device tvp7002 registeredEVM: switch to tvp7002 HD video inputths7353 1-002e: chip found @ 0x5c (DaVinci I2C adapter)ths7353 1-002e: No platform data!!vpfe-capture vpfe-capture: v4l2 sub device ths7353 registeredvpfe_register_ccdc_device: DM365 ISIFDM365 ISIF is registered with vpfe.Trying to register davinci display video device.layer=c14f8c00,layer->video_dev=c14f8d70Trying to register davinci display video device.layer=c14f9000,layer->video_dev=c14f9170davinci_init:DaVinci V4L2 Display Driver V1.0 loadedwatchdog watchdog: heartbeat 60 secTCP cubic registered
.................................................................................
after start the encoder:
captureThrFxn vitvp5150 1-00ba: tvp5150_get_vbi lines=0 std =0xffffffdeoInput = 2 gettvp5150 1-00ba: tvp5150_get_vbi lines=1 std =0xffffffstd 5 std 5 tvp5150 1-00ba: tvp5150_get_vbi lines=2 std =0xfffffftvp5150 1-00ba: tvp5150_get_vbi lines=3 std =0xfffffftvp5150 1-00ba: tvp5150_get_vbi lines=4 std =0xfffffftvp5150 1-00ba: tvp5150_get_vbi lines=5 std =0xfffffftvp5150 1-00ba: tvp5150_get_vbi lines=6 std =0xfffffftvp5150 1-00ba: tvp5150_get_vbi lines=7 std =0xfffffftvp5150 1-00ba: tvp5150_get_vbi lines=8 std =0xfffffftvp5150 1-00ba: tvp5150_get_vbi lines=9 std =0xfffffftvp5150 1-00ba: tvp5150_get_vbi lines=10 std =0xfffffftvp5150 1-00ba: tvp5150_get_vbi lines=11 std =0xfffffftvp5150 1-00ba: tvp5150_get_vbi lines=12 std =0xfffffftvp5150 1-00ba: tvp5150_get_vbi lines=13 std =0xfffffftvp5150 1-00ba: tvp5150_get_vbi lines=14 std =0xfffffftvp5150 1-00ba: tvp5150_get_vbi lines=15 std =0xfffffftvp5150 1-00ba: tvp5150_get_vbi lines=16 std =0xfffffftvp5150 1-00ba: tvp5150_get_vbi lines=17 std =0xfffffftvp5150 1-00ba: tvp5150_get_vbi lines=18 std =0xfffffftvp5150 1-00ba: tvp5150_get_vbi lines=19 std =0xfffffftvp5150 1-00ba: tvp5150_get_vbi lines=20 std =0xfffffftvp5150 1-00ba: tvp5150_get_vbi lines=21 std =0xfffffftvp5150 1-00ba: tvp5150_get_vbi lines=22 std =0xfffffftvp5150 1-00ba: tvp5150_get_vbi lines=23 std =0xffffffEVM: switch to tvp7002 HD video inputvpfe-capture vpfe-capture: error in getting g_fmt from sub deviceError: Failed to detect video standard, video input connected?Video.c: localBufferAlloc=1
thanks doron sandroy.
Hi Doron!The patch is only bit of fixes tvp5150 driver for enable outputs (because are 3state by default) and fix for PAL std.The main magic comes from the board support driver.The best way is simply replace tvp5146 with tvp5150. Both are STD (D1) video. The "encode" demo works with the tvp5150 as if it's a tvp5146.It is a transparent replacement.The first task is to integrate tvp5150 to VPFE subsystem properly.Carefully check out bus switch to enable tvp5150 bus via mux. Also, highly recommended to switch off support of any other chips: tvp7002, ths7353, tvp5148; in 'board-dm365-evm.c' file to avoid influence.Your tvp5150 i2c-address "0x174" looks strange. I again recommend to switch off other chips inside board support driver to avoid i2c conflicts."std =0xffffff" is also wrong.Complex, but effective method would be to insert a lot of "printk" inside functions like 's_routing', 'g_fmt', 's_std', etc, to check values.Be pedantic. Print all of the information from all of the necessary modules, from all the interesting functions. Print the contents of variables.Print debug strings in piece of code inside 'if' and 'else' sections to understand in which branch code execution.I spent 3 weeks on this work, before reach the goal! In the driver code I put in almost a hundred of "printk" operators. It was hard work! But in the end, I was rewarded with the result.
Here is my first log (encode demo started) related to first topic post (tvp5150 via imager). Log contains tvp5150 state after each 'tvp5150_g_fmt' call.
3000.Encode_LOG_for_TVP5150.txt
This is an example of "printk" usage for driver research. It was be very useful to understand how driver works.
senchuss
My customer followed your setps on their DM365 custom board with tvp5150.
but got one yuv picture(704x576) with black pixels as below.
Any idea for the issue? thanks!