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.

LCD Display issue (DM6446)



I tried to write a code that filled the LCD panel with one color.

But my LCD panel displayed only about 1/4 color, like this link  ↓

                                                              http://img401.imageshack.us/img401/8822/img1589rf.jpg

Could anyone tell me what reason about my code??

Thanks All!!  ^__^

 

  • can you post your code or loop for doing this?

    One think that may be happening is that your valid data region (as programmed in hardware register settings) may be larger than the visible area, hence there may be pixels being read but not shown, which would make your defined colored pixels run out sooner.  This may also have to do with buffering, if the system is doing double buffering and one of the buffers is blank, followed by de-interlacing, then you may see about half the screen blank.  Finally, keep in mind that each pixel is 16-bits (or 2 bytes in YCbCr 4:2:2 format, hence you must write enough memory to account for your chosen resolution x 2 bytes.

  • Do I set NTSC or PAL at first?? I don't do this. 

    I post my "initialize LCD" code:

    int video_output_setup(int *fdByRef, char *device, char **displayBuffersArray, 

    int numDisplayBuffers, int *displayWidthByRef, 

    int *displayHeightByRef, uint32_t zoomFactor, unsigned long physDisplays[],int *dpp)

    {

        int displayFd; // file descriptor for opened device

        struct fb_var_screeninfo varInfo; // variable display screen information

        struct fb_fix_screeninfo fixInfo;

        int frameSize, lineWidth; // line and frame sizes in bytes

        struct Zoom_Params zoom; // specifies zoom of 1x, 2x or 4x

        int i,j; // for loop index

       unsigned int            *buf;

        /* define a macro to handle the repetitive cleanup required upon failure */

       #define failure_procedure() close(displayFd);

    *fdByRef = -1;

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

       displayBuffersArray[i] = NULL;

    }

             //return VOUT_FAILURE

     

        DBG("Initializing display device: %s\n", device);

     

     

        /* Open the display device */

        displayFd = open(device, O_RDWR);

     

        if (displayFd == -1) {

            ERR("Failed to open fb device %s\n", device);

            failure_procedure();

        }

     

        DBG("\tDisplay device opened with file descriptor: %d\n", displayFd);

     

        if (ioctl(displayFd, FBIOGET_FSCREENINFO, &fixInfo) == -1) {

            ERR("Failed FBIOGET_FSCREENINFO on %s\n", device);

           failure_procedure();

        }

        /* Query driver for current state of variable screen info */

        if (ioctl(displayFd, FBIOGET_VSCREENINFO, &varInfo) == -1) {

            ERR("Failed FBIOGET_VSCREENINFO on %s\n", device);

            failure_procedure();

        }

        /* Setting xres_virtual = xres assures that a 1-d buffer will     */

        /*       properly display.  (Otherwise would require zero filling */

        /*       of unused xres_virtual for each line.)                   */

        /* Multiple frames are mapped along y-axis as yres_virtual        */

        varInfo.xres = *displayWidthByRef;

        //varInfo.xres_virtual = *displayWidthByRef;

        varInfo.yres = *displayHeightByRef;

        //varInfo.yres_virtual = 480*2/*(*displayHeightByRef*numDisplayBuffers)*/;

     

        /*  screen bits per pixel *must* be 16 -- DM6446/3 hardware req.  */

        varInfo.bits_per_pixel = SCREEN_BPP;

     

     

        /* Request video display format */

        if (ioctl(displayFd, FBIOPUT_VSCREENINFO, &varInfo) == -1) {

            ERR("Failed FBIOPUT_VSCREENINFO on file descriptor %d\n", displayFd);

            failure_procedure();

        }

        /* Map the video buffers to user space */

        /* xres_virtual = xres guarantees they can all be mapped as one      */

        /*     continuous buffer                                             */

        displayBuffersArray[0] = (char *) mmap (NULL,

                                     fixInfo.line_length * varInfo.yres_virtual,

                                     PROT_READ | PROT_WRITE,

                                     MAP_SHARED,

                                     displayFd, 0);

     

        if (displayBuffersArray[0] == MAP_FAILED) {

            ERR("Failed mmap on file descriptor %d\n", displayFd);

            return VOUT_FAILURE;

        }

     frameSize = fixInfo.line_length * varInfo.yres;

       // lineWidth = varInfo.xres * SCREEN_BPP/8;

        /*  Set the displayBuffersArray array with offsets from the one        */

        /*       continuous memory segment.                                    */

        DBG("\tMapped display buffer 0, size %d to location %p\n", frameSize,

    displayBuffersArray[0]);

        for(i = 1; i< numDisplayBuffers; i++)

         {

    displayBuffersArray[i] = displayBuffersArray[i-1] + frameSize;

    DBG("\tMapped display buffer %d, size %d to location %p\n", i,

    frameSize, displayBuffersArray[i]);

        }

     

            for (i=0; i < numDisplayBuffers; i++) 

            {

            /* Clear the video buffer */

            buf = (unsigned int *) displayBuffersArray[i];

     

            for (j = 0; j < frameSize / sizeof(unsigned int); j++) 

               {

                buf[j] = UYVY_BLACK;

               }

            physDisplays[i] = Memory_getPhysicalAddress(displayBuffersArray[i]);

            DBG("Display buffer %d mapped to %#lx has physical address %#lx\n",

                i, (unsigned long) displayBuffersArray[i], physDisplays[i]);

            }

        /* Set the display zoom factor */

     

        zoom.WindowID = VID1_INDEX;

        zoom.Zoom_H = zoomFactor;

        zoom.Zoom_V = zoomFactor;

     

        if (ioctl(displayFd, FBIO_SETZOOM, &zoom)) {

            ERR("Failed set zoom parameters on file descriptor %d\n", displayFd);

            failure_procedure();

        }

     

        DBG("\tDisplay set to %dx%d resolution\n",varInfo.xres, varInfo.yres);

        switch( zoomFactor )

        {

    case ZOOM_1X : DBG("\tZoom factor set to 1x\n");

          break;

    case ZOOM_2X : DBG("\tZoom factor set to 2x\n");

          break;

    case ZOOM_4X : DBG("\tZoom factor set to 4x\n");

          break;

    default : DBG("\tUnrecognized zoom factor\n");

        }

     

     

        /*  Set return-by-reference values and return VOUT_SUCCESS        */

        /*  (note: displayBuffersArray has already been filled)            */

     

        /* Allocated is not guaranteed to be the same as requested value.  */

        /*      return actual allocated value via provided pointers        */

        *displayWidthByRef = varInfo.xres;

        *displayHeightByRef = varInfo.yres;

     

        /* return file descriptor for newly opened device via supplied pointer */

        *fdByRef = displayFd;

        *dpp = fixInfo.line_length;

        /* return the file descriptor of the newly opened device.           */

        return VOUT_SUCCESS;

    }

     

    If "initialize LCD" id OK , I post another part .  

    Thanks All

  • wheather you set it to NTSC or PAL would depend on what capture and display device your EVM came with.  The EVM itself works with both; however, if you are using a PAL display, then you need to tell the EVM.

    With regards to your code snipet, I am unable to tell the value of varInfo.xres from it.  I believe sizeof(unsigned int) = 4.  Is this what you expect?  What value are you giving to UYVY_BLACK?  The jpg suggests light blue color, but the name suggests black?  It would be great if you can post a log of the program after a sucessful run so we can readily see all the information with regards to sizes of x and y, overall frame size... to make sure it all makes sense.

  • Now,I try to display QCIF sequence(4:2:0)

     

    int main()

    {

    static char *inBuf             = NULL; 

    static char *inBuf_1        = NULL; 

    static char *inBuf_2        = NULL;  

    static char *outBuf          = NULL; 

    //static char *displaybuf = NULL;

    Rszcopy_Handle       hRszcopy      = RSZCOPY_FAILURE;

    unsigned long PhysicalAddr;

    int  status;

    int n = 0;

    int                osdFd      = 0;     // OSD file descriptor

    int                attrFd      = 0;     // attr window file descriptor

    int            fbFd      = 0;     // video fb driver file desc

    unsigned short    *osdDisplay; // OSD display buffer

    unsigned short    *attrDisplay; // attribute display buffer

    int       displayWidth; // width of a display frame

    int  displayHeight; // height of a display frame

    unsigned long        physDisplays[NUM_DISP_BUFS];

    char              *displays[NUM_DISP_BUFS]; // display frame pointers

    int displayPitch;

    int displayIdx = 0;

    FILE *inFile;

    if ((inFile = fopen(INPUTFILE, "rb")) == NULL) 

    {  

            printf("App-> ERROR: can't read file \n");  

            exit(1);  

        }  

    status = ceapp_init();  

    if (status != 0)

    {  

            return VOSD_FAILURE;  

         }  

         //==========Allocate contigBuf and Translate to Physical Address==========//

    inBuf             = ceapp_allocContigBuf(176*144,      "input data");  

    inBuf_1        = ceapp_allocContigBuf(88*72,      "input data_1");  

    inBuf_2        = ceapp_allocContigBuf(88*72,      "input data_2");  

    outBuf          = ceapp_allocContigBuf(176*144*2,     "output data");

    //displaybuf = ceapp_allocContigBuf(176*144*2,     "display data");

    PhysicalAddr           = Memory_getPhysicalAddress(outBuf);

     

    if (inBuf == NULL || inBuf_1 == NULL || inBuf_2 == NULL || 

        outBuf == NULL /*|| displaybuf == NULL*/)

    {  

            printf("App-> Error allocating buffers (%p, %p, %p, %p)!\n",  

      inBuf, inBuf_1, inBuf_2, outBuf/*, displaybuf*/);  

            status = -1;  

            goto cleanup;  

          }  

     

    status = ceapp_validateBufSizes(176*144*1.5,  

                                         176*144*2);  

    if (status != 0)

    {  

            goto cleanup;  

         }  

     

    if( video_osd_setup(&osdFd, &attrFd, FBVID_OSD, FBVID_ATTR, 0x00, 

    &osdDisplay, &attrDisplay) == VOSD_FAILURE )

    {

    ERR("Failed video_osd_setup in video_thread_function\n");

    status = VIDEO_THREAD_FAILURE;

    goto cleanup;

                   }    

     

    displayWidth = D1_WIDTH;

    displayHeight = D1_HEIGHT;               

    if( video_output_setup(&fbFd, FBVID_VIDEO, displays, NUM_DISP_BUFS, 

    &displayWidth, &displayHeight, ZOOM_1X, physDisplays,&displayPitch) 

    == VOUT_FAILURE) 

    {

    ERR("Failed video_output_setup in video_thread_function\n");

    status = VIDEO_THREAD_FAILURE;

    goto cleanup;

                       }               

     

    hRszcopy = Rszcopy_create(RSZCOPY_DEFAULTRSZRATE);

    if (hRszcopy == RSZCOPY_FAILURE) {

    ERR("Failed to create resize copy job\n");

    status = VIDEO_THREAD_FAILURE;

    goto cleanup;

       }

        

    if (Rszcopy_config(hRszcopy, 176, 144,

                                   176 * SCREEN_BPP / 8,

                                   displayPitch) == RSZCOPY_FAILURE) 

    {

    ERR("Failed to configure resize job\n");

    status = VIDEO_THREAD_FAILURE;

    goto cleanup;

    }

    for (n = 0 ;n<FRAME_NO; n++)

    {

    printf("App-> Processing frame %d...\n", n);  

    displayIdx = (displayIdx + 1) % NUM_DISP_BUFS;

                    printf("App->displayIdx = %d\n",displayIdx);

    if (fread(inBuf, 176*144, 1, inFile) == 0)

                break;  

    if (fread(inBuf_1, 88*76, 1, inFile) == 0) 

                break;  

    if (fread(inBuf_2, 88*76, 1, inFile) == 0)

     break; 

    status = ceapp_decodeBuf(inBuf, inBuf_1,inBuf_2, 176*144,  

                                                                          outBuf,     176*144*2); 

     

    if (status != 0) 

    {  

                printf("App-> ERROR: Decoding frame %d FAILED\n", n);  

                goto cleanup;  

             }       

    //memcpy(displaybuf, outBuf,176*144*2);

    if (Rszcopy_execute(hRszcopy, PhysicalAddr, physDisplays[displayIdx]) == RSZCOPY_FAILURE) {

    ERR("Frame copy using resizer failed\n");

    status = VIDEO_THREAD_FAILURE;

    goto cleanup;

            }

     

    flip_display_buffers(fbFd, displayIdx);

    waitForVsync(fbFd);

    }     

    cleanup:

    status = video_osd_cleanup(osdFd, attrFd, osdDisplay, attrDisplay); 

    video_output_cleanup(fbFd, displays, NUM_DISP_BUFS);

    Rszcopy_delete(hRszcopy);

    printf("Finished displaying %d frames\n", n); 

    status = 0;

    fclose(inFile); 

    if (inBuf != NULL)  

            ceapp_freeContigBuf(inBuf, 176*144);   

    if (inBuf_1 != NULL)   

            ceapp_freeContigBuf(inBuf, 88*72);    

    if (inBuf_2 != NULL) 

            ceapp_freeContigBuf(inBuf, 88*72);  

    if (outBuf != NULL)

            ceapp_freeContigBuf(outBuf, 176*144*2);  

      // if (displaybuf != NULL)

            //ceapp_freeContigBuf(outBuf, 176*144*2);    

     

    /* quit the CE application */  

    ceapp_exit();         

    return status;

    }

    I do YUV420toUYVY422 at DSP-side and send back frame buffer to ARM-side.

     

    This is my code.  Is my code's flow wrong? 

    Because LCD only can display the first frame, another frames are faile. 

    QCIF resolution is 176*144, but my LCD displayed not enough 144.

  • Another part code

    #include <stdio.h>

    #include <stdlib.h>

    #include <string.h>            

     

    #include <fcntl.h>

    #include <unistd.h>

    #include <sys/mman.h>

    #include <sys/ioctl.h>

     

    #include <linux/fb.h>

    #include <xdc/std.h>

     

    #include <ti/sdo/ce/osal/Memory.h>

     

    #define VIDEO_THREAD_SUCCESS  0

    #define VIDEO_THREAD_FAILURE  -1

    #define VOSD_SUCCESS 0

    #define VOSD_FAILURE -1

    #define VOUT_SUCCESS 0

    #define VOUT_FAILURE -1

     

    #define SCREEN_BPP 16

    #define D1_WIDTH 176

    #define D1_HEIGHT 144

    #define UYVY_BLACK               0x10801080

     

    #define VID0_INDEX 0

    #define VID1_INDEX 1

    #define ZOOM_1X    0

    #define ZOOM_2X    1

    #define ZOOM_4X    2

     

    #define FBIO_SETZOOM        _IOW('F', 0x24, struct Zoom_Params)

    #define FBIO_WAITFORVSYNC   _IOW('F', 0x20, u_int32_t)

    #define FBIO_GETSTD         _IOR('F', 0x25, u_int32_t)

     

    struct Zoom_Params

    {

        u_int32_t WindowID;

        u_int32_t Zoom_H;

        u_int32_t Zoom_V;

    };

     

    static int video_osd_setup(int *osdFdByRef, int *attrFdByRef, char *osdDevice, 

    char *attrDevice, unsigned char trans, 

    unsigned short **osdDisplayByRef, 

    unsigned short **attrDisplayByRef)

    {

    int                      size;

    struct fb_var_screeninfo attrInfo;

    struct fb_var_screeninfo osdInfo;

        *osdFdByRef = open(osdDevice, O_RDWR);

     

        if (*osdFdByRef == -1) {

            ERR("Failed to open OSD device %s\n", osdDevice);

            return VOSD_FAILURE;

        }

     

        *attrFdByRef = open(attrDevice, O_RDWR);

     

        if (*attrFdByRef == -1) {

            ERR("Failed to open attribute window device %s\n", attrDevice);

    close(*osdFdByRef);

            return VOSD_FAILURE;

        }

     

        DBG("OSD device %s opened with file descriptor %d\n", osdDevice, 

    *osdFdByRef);

        DBG("Attribute device %s opened with file descriptor %d\n", attrDevice,

    *attrFdByRef);

     

     

        if (ioctl(*osdFdByRef, FBIOGET_VSCREENINFO, &osdInfo) == -1) {

            ERR("Error reading variable info for file descriptor %d\n", 

    *osdFdByRef);

    close(*attrFdByRef);

    close(*osdFdByRef);

            return VOSD_FAILURE;

        }

     

     

        /* Sixteen bits per pixel */

        size = osdInfo.xres_virtual * osdInfo.yres * 2; 

     

        *osdDisplayByRef = (unsigned short *) mmap(NULL, size,

                                              PROT_READ | PROT_WRITE,

                                              MAP_SHARED, *osdFdByRef, 0);

        if (*osdDisplayByRef == MAP_FAILED) {

            ERR("Failed mmap on file descripor %d\n", *osdFdByRef);

    close(*attrFdByRef);

    close(*osdFdByRef);

            return VOSD_FAILURE;

        }

     

        DBG("Mapped osd window to location %p, size %d (%#x)\n", *osdDisplayByRef,

    size, size);

     

        /* Fill the window with the new attribute value */

        memset(*osdDisplayByRef, 0, size);

     

        DBG("\tFilled OSD window with pattern: 0x0\n");

     

        if (ioctl(*attrFdByRef, FBIOGET_VSCREENINFO, &attrInfo) == -1) {

            ERR("Error reading variable info for file descriptor %d\n", 

    *attrFdByRef);

    close(*attrFdByRef);

    close(*osdFdByRef);

            return VOSD_FAILURE;

        }

     

     

        /* One nibble per pixel */

        size = attrInfo.xres_virtual * attrInfo.yres / 2; 

     

        *attrDisplayByRef = (unsigned short *) mmap(NULL, size,

                                              PROT_READ | PROT_WRITE,

                                              MAP_SHARED, *attrFdByRef, 0);

        if (*attrDisplayByRef == MAP_FAILED) {

            ERR("Failed mmap on file descripor %d\n", *attrFdByRef);

    close(*attrFdByRef);

    close(*osdFdByRef);

            return VOSD_FAILURE;

        }

     

        DBG("Mapped attribute window to location %p, size %d (%#x)\n", 

    *attrDisplayByRef, size, size);

     

        /* Fill the window with the new attribute value */

        memset(*attrDisplayByRef, trans, size);

     

        DBG("\tFilled attribute window with pattern: %#x\n", trans);

     

     

        return VOSD_SUCCESS;

    }

     

    static int video_output_setup(int *fdByRef, char *device, char **displayBuffersArray, 

    int numDisplayBuffers, int *displayWidthByRef, 

    int *displayHeightByRef, uint32_t zoomFactor, unsigned long physDisplays[],int *dpp)

    {

        int displayFd; // file descriptor for opened device

        struct fb_var_screeninfo varInfo; // variable display screen information

        struct fb_fix_screeninfo fixInfo;

        int frameSize; // line and frame sizes in bytes

        struct Zoom_Params zoom; // specifies zoom of 1x, 2x or 4x

        int i,j; // for loop index

       unsigned int            *buf;

        /* define a macro to handle the repetitive cleanup required upon failure */

       #define failure_procedure() close(displayFd);

    *fdByRef = -1;

    /* for(i=0; i<numDisplayBuffers; i++){ 

       displayBuffersArray[i] = NULL;

    }*/

             //return VOUT_FAILURE

     

        DBG("Initializing display device: %s\n", device);

     

     

        /* Open the display device */

        displayFd = open(device, O_RDWR);

     

        if (displayFd == -1) {

            ERR("Failed to open fb device %s\n", device);

            failure_procedure();

        }

     

        DBG("\tDisplay device opened with file descriptor: %d\n", displayFd);

     

        if (ioctl(displayFd, FBIOGET_FSCREENINFO, &fixInfo) == -1) {

            ERR("Failed FBIOGET_FSCREENINFO on %s\n", device);

           failure_procedure();

        }

        /* Query driver for current state of variable screen info */

        if (ioctl(displayFd, FBIOGET_VSCREENINFO, &varInfo) == -1) {

            ERR("Failed FBIOGET_VSCREENINFO on %s\n", device);

            failure_procedure();

        }

     

        /* Setting xres_virtual = xres assures that a 1-d buffer will     */

        /*       properly display.  (Otherwise would require zero filling */

        /*       of unused xres_virtual for each line.)                   */

        /* Multiple frames are mapped along y-axis as yres_virtual        */

        varInfo.xres = *displayWidthByRef;

        //varInfo.xres_virtual = *displayWidthByRef;

        varInfo.yres = *displayHeightByRef;

        //varInfo.yres_virtual = 480*2/*(*displayHeightByRef*numDisplayBuffers)*/;

     

        /*  screen bits per pixel *must* be 16 -- DM6446/3 hardware req.  */

        varInfo.bits_per_pixel = SCREEN_BPP;

     

     

        /* Request video display format */

        if (ioctl(displayFd, FBIOPUT_VSCREENINFO, &varInfo) == -1) {

            ERR("Failed FBIOPUT_VSCREENINFO on file descriptor %d\n", displayFd);

            failure_procedure();

        }

     

        /* Get allocated video display format */

        if (varInfo.xres != D1_WIDTH ||

            varInfo.yres != D1_HEIGHT ||

            varInfo.bits_per_pixel != SCREEN_BPP) {

            ERR("Failed to get the requested screen size: %dx%d at %d bpp\n",

                D1_WIDTH, D1_HEIGHT, SCREEN_BPP);

            return VOUT_FAILURE;

        }

     

     

         /* Map the video buffers to user space */

        /* xres_virtual = xres guarantees they can all be mapped as one      */

        /*     continuous buffer                                             */

        displayBuffersArray[0] = (char *) mmap (NULL,

                                     fixInfo.line_length * varInfo.yres_virtual,

                                     PROT_READ | PROT_WRITE,

                                     MAP_SHARED,

                                     displayFd, 0);

     

        if (displayBuffersArray[0] == MAP_FAILED) {

            ERR("Failed mmap on file descriptor %d\n", displayFd);

            return VOUT_FAILURE;

        }

     

     frameSize = fixInfo.line_length * varInfo.yres;

     

        /*  Set the displayBuffersArray array with offsets from the one        */

        /*       continuous memory segment.                                    */

        DBG("\tMapped display buffer 0, size %d to location %p\n", frameSize,

    displayBuffersArray[0]);

        for(i = 1; i< numDisplayBuffers; i++)

         {

    displayBuffersArray[i] = displayBuffersArray[i-1] + frameSize;

    DBG("\tMapped display buffer %d, size %d to location %p\n", i,

    frameSize, displayBuffersArray[i]);

        }

     

            for (i=0; i < numDisplayBuffers; i++) 

            {

            /* Clear the video buffer */

            buf = (unsigned int *) displayBuffersArray[i];

     

            for (j = 0; j < frameSize / sizeof(unsigned int); j++) 

               {

                buf[j] = UYVY_BLACK;

               }

            physDisplays[i] = Memory_getPhysicalAddress(displayBuffersArray[i]);

            DBG("Display buffer %d mapped to %#lx has physical address %#lx\n",

                i, (unsigned long) displayBuffersArray[i], physDisplays[i]);

            }

        /* Set the display zoom factor */

     

        zoom.WindowID = VID1_INDEX;

        zoom.Zoom_H = zoomFactor;

        zoom.Zoom_V = zoomFactor;

     

        if (ioctl(displayFd, FBIO_SETZOOM, &zoom)) {

            ERR("Failed set zoom parameters on file descriptor %d\n", displayFd);

            failure_procedure();

        }

     

        DBG("\tDisplay set to %dx%d resolution\n",varInfo.xres, varInfo.yres);

        switch( zoomFactor )

        {

    case ZOOM_1X : DBG("\tZoom factor set to 1x\n");

          break;

    case ZOOM_2X : DBG("\tZoom factor set to 2x\n");

          break;

    case ZOOM_4X : DBG("\tZoom factor set to 4x\n");

          break;

    default : DBG("\tUnrecognized zoom factor\n");

        }

     

     

        /*  Set return-by-reference values and return VOUT_SUCCESS        */

        /*  (note: displayBuffersArray has already been filled)            */

     

        /* Allocated is not guaranteed to be the same as requested value.  */

        /*      return actual allocated value via provided pointers        */

        *displayWidthByRef = varInfo.xres;

        *displayHeightByRef = varInfo.yres;

     

        /* return file descriptor for newly opened device via supplied pointer */

        *fdByRef = displayFd;

        *dpp = fixInfo.line_length;

        /* return the file descriptor of the newly opened device.           */

        return VOUT_SUCCESS;

    }

     

    static int flip_display_buffers(int displayFd, int displayIdx)

    {

        struct fb_var_screeninfo varInfo; // variable info for display screen

     

        /* Get current state of the display screen variable information */

        if (ioctl(displayFd, FBIOGET_VSCREENINFO, &varInfo) == -1) {

            ERR("Failed FBIOGET_VSCREENINFO\n");

            return VOUT_FAILURE;

        }

     

        /* modify y offset to select a display screen */

        varInfo.yoffset = varInfo.yres * displayIdx;

     

        /* Swap the working buffer for the displayed buffer */

        if (ioctl(displayFd, FBIOPAN_DISPLAY, &varInfo) == -1) {

            ERR("Failed FBIOPAN_DISPLAY\n");

            return VOUT_FAILURE;

        }

     

        return VOUT_SUCCESS;

    }

     

    static int waitForVsync(int displayFd)

    {

        int dummy;

     

        /* Wait for vertical sync */

        if (ioctl(displayFd, FBIO_WAITFORVSYNC, &dummy) == -1) {

           ERR("Failed FBIO_WAITFORVSYNC\n");

            return VOUT_FAILURE;

        }

     

        return VOUT_SUCCESS;

    }

     

    void video_output_cleanup(int displayFd, char **displayBuffersArray, 

    int numDisplayBuffers)

    {

        struct fb_var_screeninfo varInfo; // variable display screen info

        struct fb_fix_screeninfo fixInfo;

        int frameSize; // display frame size in bytes

     

        /* Get display frame resolution from the variable info */

        if (ioctl(displayFd, FBIOGET_VSCREENINFO, &varInfo) == -1) {

            ERR("Failed FBIOFET_VSCREENINFO for file descriptor %d\n", displayFd);

        }

        if (ioctl(displayFd, FBIOGET_VSCREENINFO, &fixInfo) == -1) {

            ERR("Failed FBIOFET_VSCREENINFO for file descriptor %d\n", displayFd);

        }

        /* Calculate frame size so we know how much to un-map */

        frameSize = varInfo.xres * varInfo.yres * SCREEN_BPP/8;

    DBG("%d",fixInfo.line_length * varInfo.yres_virtual);

        /* Un-memory-map display buffers from this process */

       // munmap(displayBuffersArray[0], frameSize * numDisplayBuffers);

    munmap(displayBuffersArray[0], fixInfo.line_length * varInfo.yres_virtual);

        DBG("unmapped contiguous display buffer block of\n");

        DBG("size %d at location %p\n", fixInfo.line_length * varInfo.yres_virtual, 

    displayBuffersArray[0]);

     

        /* Close display device */

        close(displayFd);

     

        DBG("Closed video display device (file descriptor %d)\n", displayFd);

     

    }

    static int video_osd_cleanup(int osdFd, int attrFd, unsigned short *osdDisplay, 

    unsigned short *attrDisplay)

    {

        struct fb_var_screeninfo vInfo;

        int                      size;

     

        DBG("Entering osd window cleanup\n");

     

        if (ioctl(osdFd, FBIOGET_VSCREENINFO, &vInfo) == -1) {

            ERR("Error reading variable information for file descriptor %d\n", 

    osdFd);

    close(attrFd);

    close(osdFd);

            return VOSD_FAILURE;

        }

     

        /* Sixteen bits per pixel */

        size = vInfo.xres_virtual * vInfo.yres * 2; 

     

        munmap(osdDisplay, size);

        close(osdFd);

     

        DBG("\tClosed osd window (file descriptor: %d)\n", osdFd);

        DBG("\tUnmapped osd window memory (%p)\n", osdDisplay);

     

     

        DBG("Entering attribute window cleanup\n");

     

        if (ioctl(attrFd, FBIOGET_VSCREENINFO, &vInfo) == -1) {

            ERR("Error reading variable information for file descriptor %d\n", 

    attrFd);

    close(attrFd);

    close(osdFd);

            return VOSD_FAILURE;

        }

     

        /* One nibble per pixel */

        size = vInfo.xres_virtual * vInfo.yres / 2; 

     

        munmap(attrDisplay, size);

        close(attrFd);

     

        DBG("\tClosed attribute window (file descriptor: %d)\n", attrFd);

        DBG("\tUnmapped attribute window memory (%p)\n", attrDisplay);

     

        return VOSD_SUCCESS;

    }

  • I solved this problem and succeed display in LCD panel.

    Now,I have a question.

    What the function of "waitForVsync(displayFd);" spends so much time?

    Average one frame needs 30ms.

    Could anyone tell me why??    Thanks All

    Code for waitForVsync(displayFd);

    static int waitForVsync(int fd)

    {

        int dummy;

        /* Wait for vertical sync */

        if (ioctl(fd, FBIO_WAITFORVSYNC, &dummy) == -1) {

            ERR("Failed FBIO_WAITFORVSYNC (%s)\n", strerror(errno));

            return FAILURE;

        }

        return SUCCESS;

    }

  • how much time are you measuring waitForVsync is taking?  This function is basically waiting until the current video frame has finished displaying and asserts VSYNC interrupt indicating the end of video frame.  If you are doing NTSC at 30 fps this should take 1/30 msec = 33 msec from one vsync frame to the next (maximum wait time for vsync).  Now you are not always making the function call right when the previous vsync happens, so 30 msec sounds about right.

  • I use H.264 source code JM11.0. My code is:

    ftime (&(img->tstruct_start_1));

    time( &(img->ltime_start_1));

    waitForVsync(fbFd);

    ftime (&(img->tstruct_end_1));

      time( &(img->ltime_end_1)); 

      tmp_time_1=(img->ltime_end_1*1000+img->tstruct_end_1.millitm) - (img->ltime_start_1*1000+img->tstruct_start_1.millitm);

    I print "tmp_time_1" and about spend 30 msec.

    If JM  needs 100msec to decode one frame, the function of "waitForVsync(fbFd);" needs 30 msec.

    Is it reasonable??