Hass Multimedia (MPP) development (1) - nvp6134 drive Introduction

Summary:

NVP6134C introduced in Nextchip are: 

quipped with Universal AHD™ Technology for the first time among the AHD™ product family, NVP6134C delivers highly robust and versatile video decoding solution for HD analog DVR systems.
It supports 3.0M@18fps NRT 4CH DVR systems with 2-port RX outputs. Thanks to its Universal Technology, users can now enjoy unrivaled system flexibility that is powered not only by backward compatibility for AHD formats, but also by interoperability between non-AHD formats.

Translation:

NVP6134C first time with a common AHD ™ technology AHD ™ product line, provides a highly robust and versatile solution for high-definition video decode analog DVR system. It supports 3.0M@18fps NRT 4CH DVR system with the RX output port 2. 

datasheet view it Description:

From the chip manual can know:

  1. It supports up to 4 video and audio input 5
  2. There are two data outputs, can be independently controlled, an output port may be provided, 2,4 multiplexed mode
  3. Supports multiple formats also support a variety of data input formats data output
  4. nvp6134 support 4 and a voice microphone inputs, in fact, is the analog audio signal into a digital signal, recording mode called Hass
  5. 1 audio playback, digital audio data is input nvp6134, through the 6134 digital signal into an analog audio signal output

(A) Note points:

When in use need to pay attention:

(1) end of the device I2C address

    Figure 5.2 I2C Slave Address Configuration
Note that this picture of A0 ~ A6 represents the address configuration, but not the actual address. The actual address should be bit1 ~ bit7, bit0 flag is used to indicate read and write
by hardware SA0, SA1 different addresses may represent four address, 0x60,0x62,0x64,0x66. The largest in a single device can be connected in series Section 4 of the chip.

(2) I2C read and write data

IIC IIC standard read and write data is read and written from the point of view on the chip manual, 6134C chip does not support i2c continuous read and sequential write operations.    

(3) Operation Register

In the read register 6134, when a switching of the bank note, and 6134c should have bank0 ~ bankb 12 th bank, performing read and write data, the need to switch to advance to the correct bank.
Such as chip ID is read:

/*******************************************************************************
*    Description        : Get Device ID
*    Argurments        : dec(slave address)
*    Return value    : Device ID
*    Modify            :
*    warning            :
*******************************************************************************/
int check_id(unsigned int dec)
{
    int ret;
    gpio_i2c_write(dec, 0xFF, 0x00);
    ret = gpio_i2c_read(dec, 0xf4);
    return ret;
}

(B) initialization

    Inputs and outputs for video, only need to set the input and output properties 6134 can be used directly

(1) NVP6134 channel input is provided:

    The main operating nvp6134_chn_mode structure, standard resolution set the channel properties.

int Set_NVP6134_ChannelMode(void)
{
    int i = 0;
    int l_s32Fd = -1;
    int l_s32Ret = 0;
    int l_s32ChipCount = 1;
    nvp6134_chn_mode schnmode;

    bzero(&schnmode,sizeof(nvp6134_chn_mode));

    l_s32Fd = open(NVP6134_FILE, O_RDWR);
    if (l_s32Fd < 0)
    {
        printf("[%s:%d] open nvp6134 (%s) fail\n", __func__, __LINE__, NVP6134_FILE);
        return -1;
    }

    for(i=0;i<l_s32ChipCount*4;i++)
    {
        schnmode.ch = i;
        schnmode.vformat = PAL;
        schnmode.chmode  = NVP6134_VI_960H;
        ioctl(l_s32Fd, IOC_VDEC_SET_CHNMODE, &schnmode);
    }

    close(l_s32Fd);

    return 0;
}

    It should be noted that to set video system format, 6134 support PAL and NTSC. If the camera format consistent with the actual access, will eventually lead to not receive data, the phenomenon is manifested, Hass VI acquired image data is small, the screen is black.

     These video resolution parameters, the very beginning of the initialization may be any value, and then to re-initialization may then be detected by IOC_VDEC_GET_INPUT_VIDEO_FMT, each channel detected actual input resolution of the camera

int Check_NVP6134_VideoInputFMT(void)
{
    int l_s32Fd = -1;
    int i = 0;
    int l_s32Ret = 0;
    nvp6134_input_videofmt stInputFMT;

    bzero(&stInputFMT,sizeof(nvp6134_input_videofmt));

    l_s32Fd = open(NVP6134_FILE, O_RDWR);
    if (l_s32Fd < 0)
    {
        printf("[%s:%d] open nvp6134 (%s) fail\n", __func__, __LINE__, NVP6134_FILE);
        return -1;
    }

    l_s32Ret = ioctl(l_s32Fd, IOC_VDEC_GET_INPUT_VIDEO_FMT, &stInputFMT);
    if(l_s32Ret < 0)
    {
        printf("[%s,%d][l_s32Ret:%d]\n",__FILE__,__LINE__,l_s32Ret);
    }

    close(l_s32Fd);


    for(i=0;i<4;i++)
    {
        printf("i=%d videofmt     =0x%x \n",i,stInputFMT.getvideofmt[i]);
        printf("i=%d inputvideofmt=0x%x \n\n",i,stInputFMT.inputvideofmt[i]);
    }

    return 0;
}

    On my device is connected all the way all the way to 1080P and 720P, the actual test results are as follows:

i=0 videofmt     =0x72 
i=0 inputvideofmt=0x0 

i=1 videofmt     =0x0 
i=1 inputvideofmt=0x0 

i=2 videofmt     =0x12 
i=2 inputvideofmt=0x0 

i=3 videofmt     =0x0 
i=3 inputvideofmt=0x0

 Numerical relationship between the detection result of the drive can be viewed as part of the driver:

unsigned char nvp6134_vfmt_convert(unsigned char vdsts, unsigned char g_ck_fmt)
{
	unsigned int ret;
	switch(vdsts)
	{
		case 0x00:  ret = 0x01;	break;  //cvbs ntsc
		case 0x10:  ret = 0x02; break;	//cvbs pal
		case 0x20:	ret = 0x04; break;	//720p ntsc
 		case 0x21:  ret = 0x08; break;	//720p pal
		case 0x22:  ret = 0x51; break;	//720P@RT ntsc
		case 0x23:  ret = 0x52; break;	//720P@RT pal
		case 0x30:  ret = 0x40;	break;	//1080p ntsc
		case 0x31:	ret = 0x80;	break;	//1080p pal
		case 0x2B:  ret = 0x11; break;  //HD exc  @ 30P
		case 0x2C:  ret = 0x12; break;  //HD EXC  @ 25P
		case 0x25:  ret = 0x31; break;  //HD EXT  @ 30A
		case 0x26:  ret = 0x32; break;  //HD EXT  @ 24A
		case 0x29:  ret = 0x34; break;  //HD EXT  @ 30B
		case 0x2A:  ret = 0x38; break;  //HD EXT  @ 25B
		case 0x2D:  ret = 0x51; break;  //HD EXC  @ 60P
		case 0x2E:  ret = 0x52; break;  //HD EXC  @ 50P
		case 0x27:  ret = 0x54; break;  //HD EXT  @ 60
		case 0x28:  ret = 0x58; break;  //HD EXT  @ 50
		case 0x35:  ret = 0x71; break;  //FHD EXC @ 30P
		case 0x36:  ret = 0x72; break;  //FHD EXC @ 25P
		case 0x33:  ret = 0x74; break;  //FHD EXT @ 30P
		case 0x34:  ret = 0x78; break;  //FHD EXT @ 25P
//		case 0x3F:  ret = 0x44; break;  //FHD NRT @ 30P
		case 0x40:  ret = 0x81; break;  //QHD AHD @ 30P
		case 0x41:  ret = 0x82; break;  //QHD AHD @ 25P
		case 0x4F:  ret = 0x83; break;  //QHD AHD @ NRT(15P)
		case 0xA0:  ret = 0xA0; break;  //5M AHD @ 12.5P
		case 0xA1:	ret = 0xA1;	break;	//5M 20P
		case 0xA2:	ret = 0xA2;	break;	//EXT @ 5M @ 12.5p
		case 0x03:
		case 0x04:	ret = 0x90;	break;	//AHD @ 3M NRT-18p
		case 0x64:	ret = 0x93;	break;	//EXT @ 3M NRT-18p
		case 0x01:
		case 0x02:
			if((g_ck_fmt>>4) == 0x02)	ret = 0x91;	//AHD @ 3M RT-30P
			else 						ret = 0x92;	//AHD @ 3M RT-25P
		break;	
		default:
		case 0xFF:	ret = 0x00;	break;	//not detects
	}
	return ret;
}

2.NVP6134 output mode settings:

    Nvp6134_opt_mode output mode is an operation structure, a 6134 has two output ports, can be set independently, it can be set to 2,4 multiplexed mode.

int Set_NVP6134_OutputMode(void)
{
    int i = 0;
    int l_s32Fd = -1;
    int l_s32Ret = 0;
    int l_s32ChipCount = 1;
    nvp6134_opt_mode l_stOutputMode;

    bzero(&l_stOutputMode,sizeof(nvp6134_chn_mode));

    l_s32Fd = open(NVP6134_FILE, O_RDWR);
    if (l_s32Fd < 0)
    {
        printf("[%s:%d] open nvp6134 (%s) fail\n", __func__, __LINE__, NVP6134_FILE);
        return -1;
    }

    for(i=0;i<l_s32ChipCount;i++)
    {
        l_stOutputMode.chipsel = i;
        l_stOutputMode.portsel = 2;
        l_stOutputMode.portmode = NVP6134_OUTMODE_4MUX_SD;
        l_stOutputMode.chid = 0;
        ioctl(l_s32Fd, IOC_VDEC_SET_OUTPORTMODE, &l_stOutputMode);
        l_stOutputMode.chipsel = i;
        l_stOutputMode.portsel = 1;
        l_stOutputMode.portmode = NVP6134_OUTMODE_4MUX_SD;
        l_stOutputMode.chid = 0;
        ioctl(l_s32Fd, IOC_VDEC_SET_OUTPORTMODE, &l_stOutputMode);
    }

    close(l_s32Fd);

    return 0;
}

6134 corresponding to the output mode settings need to interact with the input video VI is provided Hass, is otherwise not receive data.

Complete test procedure is as follows:

/************************************************************
*Copyright (C), 2017-2027,lcb0281at163.com lcb0281atgmail.com
*FileName: nvp6134_debug.c
*Date:     2020-03-01
*Author:   Caibiao Lee
*Version:  V1.0
*Description:测试NVP6134驱动
*Others:
*History:
***********************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <sys/ioctl.h>
#include <sys/types.h>    
#include <sys/stat.h> 
#include <fcntl.h>

#include "../nvp6134.h"
#include "../video.h"


#define NVP6134_FILE    "/dev/nvp6134"


int Check_NVP6134_VideoInputFMT(void)
{
    int l_s32Fd = -1;
    int i = 0;
    int l_s32Ret = 0;
    nvp6134_input_videofmt stInputFMT;

    bzero(&stInputFMT,sizeof(nvp6134_input_videofmt));

    l_s32Fd = open(NVP6134_FILE, O_RDWR);
    if (l_s32Fd < 0)
    {
        printf("[%s:%d] open nvp6134 (%s) fail\n", __func__, __LINE__, NVP6134_FILE);
        return -1;
    }

    l_s32Ret = ioctl(l_s32Fd, IOC_VDEC_GET_INPUT_VIDEO_FMT, &stInputFMT);
    if(l_s32Ret < 0)
    {
        printf("[%s,%d][l_s32Ret:%d]\n",__FILE__,__LINE__,l_s32Ret);
    }

    close(l_s32Fd);


    for(i=0;i<4;i++)
    {
        printf("i=%d videofmt     =0x%x \n",i,stInputFMT.getvideofmt[i]);
        printf("i=%d inputvideofmt=0x%x \n\n",i,stInputFMT.inputvideofmt[i]);
    }

    return 0;
}


int Set_NVP6134_ChannelMode(void)
{
    int i = 0;
    int l_s32Fd = -1;
    int l_s32Ret = 0;
    int l_s32ChipCount = 1;
    nvp6134_chn_mode schnmode;

    bzero(&schnmode,sizeof(nvp6134_chn_mode));

    l_s32Fd = open(NVP6134_FILE, O_RDWR);
    if (l_s32Fd < 0)
    {
        printf("[%s:%d] open nvp6134 (%s) fail\n", __func__, __LINE__, NVP6134_FILE);
        return -1;
    }

    for(i=0;i<l_s32ChipCount*4;i++)
    {
        schnmode.ch = i;
        schnmode.vformat = PAL;
        schnmode.chmode  = NVP6134_VI_960H;
        ioctl(l_s32Fd, IOC_VDEC_SET_CHNMODE, &schnmode);
    }

    close(l_s32Fd);

    return 0;
}

int Set_NVP6134_OutputMode(void)
{
    int i = 0;
    int l_s32Fd = -1;
    int l_s32Ret = 0;
    int l_s32ChipCount = 1;
    nvp6134_opt_mode l_stOutputMode;

    bzero(&l_stOutputMode,sizeof(nvp6134_chn_mode));

    l_s32Fd = open(NVP6134_FILE, O_RDWR);
    if (l_s32Fd < 0)
    {
        printf("[%s:%d] open nvp6134 (%s) fail\n", __func__, __LINE__, NVP6134_FILE);
        return -1;
    }

    for(i=0;i<l_s32ChipCount;i++)
    {
        l_stOutputMode.chipsel = i;
        l_stOutputMode.portsel = 2;
        l_stOutputMode.portmode = NVP6134_OUTMODE_4MUX_SD;
        l_stOutputMode.chid = 0;
        ioctl(l_s32Fd, IOC_VDEC_SET_OUTPORTMODE, &l_stOutputMode);
        l_stOutputMode.chipsel = i;
        l_stOutputMode.portsel = 1;
        l_stOutputMode.portmode = NVP6134_OUTMODE_4MUX_SD;
        l_stOutputMode.chid = 0;
        ioctl(l_s32Fd, IOC_VDEC_SET_OUTPORTMODE, &l_stOutputMode);
    }

    close(l_s32Fd);

    return 0;
}


int main(void)
{
    Check_NVP6134_VideoInputFMT();
    Set_NVP6134_ChannelMode();
    Set_NVP6134_OutputMode();
    Check_NVP6134_VideoInputFMT();
}

NVP6134C Datasheet and driver code download path:

nvp6134C_driver_datasheet.rar

 

The first article in this column "catalog preface," lists the complete directory column, read by directory order to help your understanding.

 

 

Published 175 original articles · won praise 262 · views 700 000 +

Guess you like

Origin blog.csdn.net/li_wen01/article/details/104431047