This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

some troubles for TVP5150

Other Parts Discussed in Thread: TVP5150AM1, TVP5150

Dear Larry,

I designed a MP4 recorder which its fornt port use  a TVP5150AMI(Video A/D). Now the troubles are as following(Mainly aimed at NTSC formats):
when my MP4 recorder is working,  video port access color camras over a period of time, the recording of data is normal; then, the fornt cameras  is switched  into the black-white cameras, the recording data is normal too;  But the cameras is changed into color cameras again, the recording data is  the black and white pictures, no color pictures. When this happerns,  Once the reset, equipment  is working normally.

Hope for your answer as soon

Best Regards,

 

jason  sun

2010-8-17

 

  •  

    Hi Jason,

    Are you currently running TVP5150AM1 patch code?  There was an issue with the TVP5150AM1 recovering from a no color burst condition.  Try using the V048CAA TVP5150AM1 patch code avialable at the link below.  Release notes and a patch code load application note are included in the zip file.

    http://software-dl.ti.com/dsps/dsps_public_sw/dsps_swops_houston/ANALOG_VIDEO/Analog_Video_Decoder_Versions.htm

    Regards,

    Larry

  • Dear Larry,

           Thanks your response.

          Due to our  second development,   there is no the development environment, we  cannot update  the FARMWORK OF TVP5150.  will you give me the volid idea to improve our troubles?    The attached file is  the initializing file for TVP5150 which we had.

          Hope for your anwer. 

    Best  Regards,

    Jason sun

    2010-AUG-18th

     #include <linux/string.h>
    #include <linux/slab.h>
    #include <linux/module.h>
    #include <linux/config.h>
    #include <linux/errno.h>
    #include <linux/miscdevice.h>
    #include <linux/fcntl.h>

    #include <asm/uaccess.h>


    #include <linux/init.h>
    #include <linux/delay.h>
    #include <linux/proc_fs.h>
    #include <linux/workqueue.h>

    #include "hi_i2c.h"
    #include "hi_gpio.h"

    #include "video_def.h"
    #include "tvp5150.h"

    #define I2C_TVP5150 0xBA
    #define PND_PIN 2
    #define OUTP 1

     static int ccirmode_flag = 0;


     static char tvp5150cfg[]= {
     0x00, 0x00,
     0x04, 0x0c,
     0x02, 0x32,
     0x07, 0x20,
     0x0a, 0x90,
     0x0c, 0x90,
     0x0d, 0x07,
     0x03, 0x6b,
    };

     

     
    static int write_regs(unsigned char *pdevdata,   unsigned long datalen)
    {
     int i = 0;
                 
        while (i < datalen)
        {
            hi_i2c_write(I2C_TVP5150,pdevdata[i], pdevdata[i+1]);    
            i += 2;
     } 
     return 0;
    }

    static int init_adv(void)
    {
     int err = 0;
     if (write_regs((unsigned char *)&tvp5150cfg, sizeof(tvp5150cfg)) != 0)
       {
             err = -1;
                printk("err_out_free_encoder\n");
                return -1;
        } 
        return(0);     
    }

    /*
     * tvp5150 initialise routine.
     
     * @param devccir: tvp5150's working mode:0--VIDEO_MODE_CCIR656; 1--VIDEO_MODE_CCIR601
     * @return value:0--success; 1--error. 
     */
    static int init_tvp5150(int devccir)

     if(devccir > VIDEO_MODE_CCIR601)
             goto err_out;

            if(devccir == VIDEO_MODE_CCIR656)
     {
      /* Set tvp5150 in ccir656 mode */
      if(hi_i2c_write(I2C_TVP5150, 0x0d, 0x47) != 0)
       return -1;
      /* Set tvp5150's data port active, but hsync and vsync not active, for ccir656 is not needed. */
      if(hi_i2c_write(I2C_TVP5150, 0x03, 0x69) != 0)
       return -1;
       
      return 0;
     } 
     else if(devccir == VIDEO_MODE_CCIR601)
     {  
      /* Set tvp5150 in ccir601 mode */
      if(hi_i2c_write(I2C_TVP5150, 0x0d, 0x40) != 0)
       return -1;
      
      /* Set tvp5150's data port active, but hsync and vsync not active, for ccir601 is needed. */
      if(hi_i2c_write(I2C_TVP5150, 0x03, 0x6f) != 0)
       return -1;
       
      return 0;   
     }
     else
      return -1;         
    err_out:
     return -1;      
    }


    int tvp5150_open(struct inode * inode, struct file * file)
    {

     return 0;
    }

    int tvp5150_close(struct inode * inode, struct file * file)
    {
     
     return 0;
    }

    static int tvp5150_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
    {
     int ret = -ENOIOCTLCMD;
     int norm_flag;
     
     switch(cmd)
     {
    #if 1
      /*set tvp5150's  mode: 0-ccir656;1-ccir601.*/
      case TVP5150_SET_CCIRMODE:
      {
       ret = get_user(ccirmode_flag, (int *)arg);
       
       if((ccirmode_flag == VIDEO_MODE_CCIR656)||(ccirmode_flag == VIDEO_MODE_CCIR601))
       {
        if(init_tvp5150(ccirmode_flag) != 0)
         ret = -EFAULT;   
       }
       else
        ret = -EINVAL;
      }
      break;

      /*get tvp5150's mode */
      case TVP5150_GET_CCIRMODE:
      {
       ret = copy_to_user((int *)arg, &ccirmode_flag,
           sizeof(ccirmode_flag)) ? -EFAULT : 0;
      }
      break;
    #endif  


      case TVP5150_GET_NORM:
      {
       /* When here we get 0x83, means PAL cvbs signal is connected. */
       if((hi_i2c_read(I2C_TVP5150,0x8c)&0x03) == 0x03)
        norm_flag = VIDEO_NORM_PAL;
       /* When we get 0x81, means NTSC. */
       else if((hi_i2c_read(I2C_TVP5150,0x8c)&0x01) == 0x01)
        norm_flag = VIDEO_NORM_NTSC;
       else
       {
        printk("Unsupported video norm.\n");
        norm_flag = -EFAULT;
       }
       ret = copy_to_user((int *)arg, &norm_flag,
           sizeof(norm_flag)) ? -EFAULT : 0;   
      }
      break;

      default:
       printk("Unrecongnised command.\n");
       ret =  -EINVAL;
      break;
     }
     
     return ret;
    }

    static struct file_operations tvp5150_fops = {
     .owner  = THIS_MODULE,
     .ioctl  = tvp5150_ioctl,
     .open  = tvp5150_open,
     .release = tvp5150_close
    };

    static struct miscdevice tvp5150_dev = {
     MISC_DYNAMIC_MINOR,
     "tvp5150",
     &tvp5150_fops,
    };

    static int tvp5150_device_init(void)
    {
        unsigned char regvalue1,regvalue2;
        regvalue1 = hi_i2c_read(I2C_TVP5150,0x07);
        hi_i2c_write(I2C_TVP5150,0x07, 0xa5);
        regvalue2 = hi_i2c_read(I2C_TVP5150,0x07);
        if(regvalue2 != 0xa5)
        {
            printk("read tvp5150 register is %x\n",regvalue2);
            printk("check tvp5150 error.\n");
            return -EFAULT;       
        }
        hi_i2c_write(I2C_TVP5150,0x07, regvalue1);
       
        if(init_adv()==0)
         return(0);
        else
         return -EFAULT;
          
    /*    if(norm_mode == VIDEO_NORM_NTSC)
        {
         if(init_vda(VIDEO_MODE_CCIR656,VIDEO_NORM_NTSC, VIDEO_MODE_MASTER) == 0)
             return 0;    
         else
             return -EFAULT;      
        }
       
        else
        {
         if(init_vda(VIDEO_MODE_CCIR656,VIDEO_NORM_PAL, VIDEO_MODE_MASTER) == 0)
             return 0;    
         else
             return -EFAULT;   
        }
    */
    }

    static int __init tvp5150_init(void)
    {
     int ret = 0;

     ret = misc_register(&tvp5150_dev);
     if(ret)
     {
      printk("could not register tvp5150 devices. \n");
      return ret;
     }
     if(tvp5150_device_init()<0){
      misc_deregister(&tvp5150_dev);
      printk("tvp5150 driver init fail for device init error!\n");
      return -1;
     }

     printk("tvp5150 driver init successful!\n");
     return ret;
    }

    static void __exit tvp5150_exit(void)
    {
     
     misc_deregister(&tvp5150_dev);


    }

    module_init(tvp5150_init);
    module_exit(tvp5150_exit);

    #ifdef MODULE
    #include <linux/compile.h>
    #endif

    //module_param(norm_mode, int, S_IRUGO);

    //MODULE_INFO(build, UTS_VERSION);

    MODULE_LICENSE("GPL");
    //MODULE_AUTHOR("hisilicon");

     

  • Dear Larry,

         I tested my device more times , and found that the troubles is  resolved by the switching of PAL/NTSC. Thus, may you tell me which registers  are set by input switching  between  PAL and NTSC?  can I set these registers by I2C?  if can ,  are their values  the default ? 

        Look forwards to your response.

      Best  Regards,

     

    Jason sun.

  • Hi Larry & Jason,

            I have the same trouble in my IP camera project too. If this problem can be solved by setting some registers, please let me know. Thanks a lot.

    Best Regards,

    Scotty