Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

Treat video data stream on Bitec

Hello !

I have questions about the Bitec HSMC Quad Video daughter card. I am a newbie on Quartus II, Nios II and the Bitec environment and I have been reading the literature for weeks and I have lots of difficulties to understand it. I managed to display the mosaic given file on NIOS II but I don't manage to treat the video stream (access to the registers...). I read altera and nios II literature about hal, hal api but did not understand how to do it. For example, I put two inputs video camera and I would like to add the two video data streams and display the added signals on the screen.

I thought about interruptions from the DMA in order to stop the stream, capture an image and treat it, but I did not understand how to do this. Is this a good idea ? Do you have examples from this card where you treat video streams ? Or could you give me a hint (or part of code to add to the nios II code) on how to do this ?

Thank you very much, I'm lost.

8 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi....Can you send me the link of which design example you are using? Are you using clocked video input one? I am able to use this Bitec QV board to get all the four camera inputs and later use these input video streams in my algorithms later. Which board are you using this QV card with?

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Yeah I have worked with this design. Actually this design is using the TVP5154 scalers to scale down the standard NTSC input image to fit in four mosaics using the faster SSRAM.

    If you have to work with unscaled input images, you need to do away with the scaling.

    i2c_write(I2C_BASE, 0xb8>>1, 0x1F, 0x00);// this will disable the scaling.

    Later the output is going through the VGA controller of 640x480 resolution to the Chrontel chip as DVI output.

    You can stop the channels or configure any of the four input video streams to get unscaled input , do your processing and then have a DVI output on 640x480 or even you can upgrade your VGA to 1024x768 resolution.

    You can get the register setting from the TVP5154 user guide.

    Rama.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thank you for your answer. I will try what you said to have unscaled image. What you described after is exactly what I want to do. Could you please precise how to stop channels and treat them ? I have read the CH7010 datasheet and the TVP5154 datasheet but I did not find this information. Maybe I passed by because I did not understand. Could you tell me the page (http://focus.ti.com/lit/ds/symlink/tvp5154.pdf) where to find this information or send me a part of your code treating a video data stream ?

    Thank you,

    Myriam
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    You have to do away with the scaling to get the raw unscaled input video stored in your ram video buffer. For that you have to decide what should be your avid etc which will depend on your camera specifications because the tvp5154 will assume it to be standard NTSC and in case your input video is not standard NTSC, it will upset your input video buffers.

    you can stop or start any channel by writing 0 or 1 respectively to this register : IOWR(video_in_base[cam_id], 0x0, 1 ); where cam_id can be 0,1,2 or 3.

    If you want to have unscaled input, stop scaling and use registers 11,12,13,14 and set your pane registers accordingly. In the demo code , all those registers used after

    i2c_write(I2C_BASE, 0xb8>>1, 0x1F, 0x01 ); // Enable scaler mode

    is just for scaling images down to 320x240 resolution. So you may not need them.

    Rama.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Rama,

    Your help is very precious. I am trying to put into practice what you told me but I still have a few problems... It does not work yet.

    The camera I am using is SDZ-375P and it is in PAL format (http://www.samsungcctvusa.com/products/productdetail.aspx?productid=55#). Thus, I don't really know which values to choose for the AVID start and Stop bit. I put 0 and 740 according to the DVI format but I don't think it's right.

    Furthermore, I don't understand how the pane register is coded. Each time I tried to change value (even with the mosaic model), it did not work.

    IOWR(video_in_base, 0x3 ,((640-318)*2 << 16) | (640-318)*2 ); //why 218 and not 320 ... ?

    in my case, it should be something like : " iowr(video_in_base, 0x3 , ((640-318)*4 << 16) | (640-318)*4 ); " because it is twice bigger (...) ?

    Do I have to specify somewhere that I am working in PAL format, for example by setting : " i2c_write(I2C_BASE, 0xb8>>1, 0x0f, 0x04); "

    I put a part of my code below for you to better understand my problems.

    while( i < 4);

    for(i=0;i<4;i++){

    i2c_write(I2C_BASE, 0xb8>>1, 0xfe, (1<<i) ); //

    i2c_write(I2C_BASE, 0xb8>>1, 0x7f, 0x00); //

    // i2c_write(I2C_BASE, 0xb8>>1, 0x0f, 0x04); // PAL mode ?

    i2c_write(I2C_BASE, 0xb8>>1, 0x03,0x0D); //

    i2c_write(I2C_BASE, 0xb8>>1, 0x05,0x0C); // Enable Clock 2 output

    i2c_write(I2C_BASE, 0xb8>>1, 0x17,0x1B);

    i2c_write(I2C_BASE, 0xb8>>1, 0x15,0x81); // Enable Stable Sync mode

    i2c_write(I2C_BASE, 0xb8>>1, 0x00,0x00); // Select video source

    // Initialise video input cores

    IOWR(video_in_base, 0x0, 0 ); // stop channel

    iowr(video_in_base, 0x2, IMAGE_MEMORY + video_in_addr);

    iowr(video_in_base, 0x3 , ((640-318)*4 << 16) | 318*4 ); // ??

    }

    // Main loop

    while ( 1 == 1 )

    for(i=0;i<4;i++){

    i2c_write(I2C_BASE, 0xb8>>1, 0xff, (1<<i) );

    if(i2c_read(I2C_BASE, 0xb8>>1, 0x88) & 0x06)//Vertical sync and horizontal sync are locked

    {

    i2c_write(I2C_BASE, 0xb8>>1, 0xfe, (1<<i) );

    i2c_write(I2C_BASE, 0xb8>>1, 0x1F, 0x00);// Disables the scaling.

    i2c_write(I2C_BASE, 0xb8>>1, 0x11, 0x00 ); //MSB de AVID start Video (0)

    i2c_write(I2C_BASE, 0xb8>>1, 0x12, 0x00 ); //LSB de AVID start Video(0)

    i2c_write(I2C_BASE, 0xb8>>1, 0x13, 0xB9 ); //MSB de AVID stop Video (740)

    i2c_write(I2C_BASE, 0xb8>>1, 0x14, 0x00 ); //LSB de AVID stop Video (740)

    /*

    // I think it is not useful

    i2c_write(I2C_BASE, 0xb8>>1, 0x18, 0x03 ); //Vertical Blanking Start Register (576)

    i2c_write(I2C_BASE, 0xb8>>1, 0x19, 0x03 ); //Vertical Blanking Stop Register (0)

    */

    i2c_write(I2C_BASE, 0xb8>>1, 0xff, (1<<i) );

    IOWR(video_in_base, 0x0, 1 ); // start channel

    } else

    iowr(video_in_base, 0x0, 0 ); // stop channel

    }

    Thank you for your patience,

    Myriam
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi,

    I have been doing some modification since tuesday. I found values of the Avid Start pixel (2), Stop pixel (-22) and pane register (IOWR(video_in_base[0], 0x3 , (640<< 16) | 1920 )) so that I have a video displayed on the screen. It is wide enough but it is not high enough. It is only 2/3 (even less) of the screen and the image is flattened.

    I found those values experimentally and still don't understand how the Avid Start and stop pixels and the pane register are related (still don't understand either the values (640-318)*2 for the pane outer an 318*2 for the inner pane in the mosaic example). If you could lighten me on this subject.

    In case I am on the right way (am I ?), I would like to have my image on a full screen. Thus, I tried to settle the vertical blanking start and stop registers by enabling vertical blanking in the 3rd register but I don't manage to change those values.

    Here is my new code :

    for(i=0;i<4;i++){

    i2c_write(I2C_BASE, 0xb8>>1, 0xfe, (1<<0) );

    i2c_write(I2C_BASE, 0xb8>>1, 0x03,0x0F); // Enable VBLK

    i2c_write(I2C_BASE, 0xb8>>1, 0x05,0x0C); // Enable Clock 2 output

    i2c_write(I2C_BASE, 0xb8>>1, 0x17,0x1B);

    i2c_write(I2C_BASE, 0xb8>>1, 0x15,0x81); // Enable Stable Sync mode

    i2c_write(I2C_BASE, 0xb8>>1, 0x00,0x00); // Select video source

    // Initialise video input cores

    IOWR(video_in_base[0], 0x0, 0 ); // stop channel

    IOWR(video_in_base[0], 0x2, IMAGE_MEMORY + video_in_addr[0]);

    IOWR(video_in_base[0], 0x3 , ((640) << 16) | 1920 );

    }

    // Main loop

    # define SV 20

    int StopVideo = -SV;

    while ( 1 == 1 )

    for(i=0;i<4;i++){

    i2c_write(I2C_BASE, 0xb8>>1, 0xff, (1<<0) );

    if(i2c_read(I2C_BASE, 0xb8>>1, 0x88) & 0x06) //Vertical sync and horizontal sync are locked

    {

    i2c_write(I2C_BASE, 0xb8>>1, 0xfe, (1<<0) ); //reçoit commandes i2c

    i2c_write(I2C_BASE, 0xb8>>1, 0x1F, 0x00);// disables the scaling.

    i2c_write(I2C_BASE, 0xb8>>1, 0x11, 0 ); //MSB de AVID start Video (1)

    i2c_write(I2C_BASE, 0xb8>>1, 0x12, 2 ); //LSB de AVID start Video(1)

    i2c_write(I2C_BASE, 0xb8>>1, 0x13, StopVideo); //MSB de AVID stop Video

    i2c_write(I2C_BASE, 0xb8>>1, 0x14, 2 ); //LSB de AVID stop Video

    i2c_write(I2C_BASE, 0xb8>>1, 0x18, 48 ); //Vertical Blanking Start Register

    i2c_write(I2C_BASE, 0xb8>>1, 0x19, 48 ); //Vertical Blanking Stop Register

    i2c_write(I2C_BASE, 0xb8>>1, 0xff, (1<<0) ); // Chacun des décodeurs lit l'i2c

    IOWR(video_in_base[0], 0x0, 1 ); // start channel

    } else

    IOWR(video_in_base[0], 0x0, 0 ); // stop channel

    }

    Sorry for the length of my message and thank you for your help,

    Myriam