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.

How to enable DM8168's VGA output with 1080P@60 resoluton

Hi,  All

      I'm debugging our own DM8168 board which has a VGA port and HDMI port.

       The HDMI port worked with following command,

       test_fb_api -d /dev/fb0

     

/**
 * @file test_fb_api.c
 * @brief
 * @author Lee Rong <rongle@126.com>
 * @version 1.0.0
 * @date 2014-02-08
 */
/* Copyright (C) 2009-2014.
 * All right reserved
 *
 */

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <getopt.h>

void pattern_gen_cbar_v_argb(unsigned char *addr, int width, int height)
{
    int i, j, k;
    unsigned int *p;
    unsigned int colorbar[8] = {
#if 0 // ABRG
        0xffffffff,     /* WHITE */
        0xff00ffff,     /* YELLOW */
        0xffff00ff,     /* CYAN */
        0xff0000ff,     /* GREEN */
        0xffffff00,     /* MAGENTA */
        0xff00ff00,     /* RED */
        0xffff0000,     /* BLUE */
        0xff000000      /* BLACK */
#else //ARGB
        0xffffffff,     /* WHITE */
        0xffffff00,     /* YELLOW */
        0xff00ffff,     /* CYAN */
        0xff00ff00,     /* GREEN */
        0xffff00ff,     /* MAGENTA */
        0xffff0000,     /* RED */
        0xff0000ff,     /* BLUE */
        0xff000000      /* BLACK */
#endif
    };

    p = (unsigned int *)addr;
    // vertical colorbar
    for (k = 0; k < height; k++) {
        for (i = 0; i < 8; i++) {
            for (j = 0; j < width / 8; j++) {
                *(p++) = colorbar[i];
            }
        }
    }
}

void printUsage(char **argv)
{
    printf("                                                     \n\
	       usage:  %s [opts] <file>                              \n\
	       \n\
	       Options:                                              \n\
	       -d       Device node  /dev/fb0-fb2                    \n\
	       -W       width of OSD plane                           \n\
	       -H       heigth of OSD plane                          \n\
	       -x       x-offset of OSD plane                        \n\
	       -y       y-offset of OSD plane                        \n\
	       -f       display ayuv, argb, yuv, rgb file            \n\
	       ", argv[0]);
}

int main(int argc, char **argv)
{
    int fbfd = 0;
    struct fb_var_screeninfo vinfo;
    struct fb_fix_screeninfo finfo;
    long int screensize = 0;
    unsigned char *fbp = NULL;
    char *filename = NULL;
    FILE *file_in = NULL;
    /* jpeg size */
    unsigned int jpeg_size = 0;
    /* jpeg resolution */
    int jpeg_width = 720;
    int jpeg_height = 480;
    /* jpeg buffer pointer */
    unsigned char *jpeg_buf = NULL;
    /* rgb buffer pointer */
    unsigned char *rgb_buf = NULL;
    char *fbnode = "/dev/fb0";
    unsigned int width, height, xoffset, yoffset;
    int c = 0;
    unsigned int i = 0, j = 0;
    char const *short_options = "d:W:H:x:y:f:h";
    static struct option long_options[] = {
        {"fbnode",  required_argument,   NULL,    'd'},
        {"width",   required_argument,   NULL,    'W'},
        {"height",  required_argument,   NULL,    'H'},
        {"xoffset", required_argument,   NULL,    'x'},
        {"yoffset", required_argument,   NULL,    'y'},
        {"jpegfile", required_argument,   NULL,    'f'},
        {"help",    no_argument,         NULL,    'h'},
        {NULL,      no_argument,         NULL,     0},
    };

    /* get parameter */
    while ((c = getopt_long(argc, argv, short_options, long_options, NULL)) != -1) {
        switch (c) {
            case 'd':
                printf("Device node %s\n", optarg);
                fbnode = optarg;
                if (fbnode == NULL) {
                    printf("Invalid fbnode: %s\n", fbnode);
                    return -1;
                }
                break;
            case 'W':
                width = atoi(optarg);
                printf("Plane width %d\n", width);
                break;
            case 'H':
                height = atoi(optarg);
                printf("Plane height %d\n", height);
                break;
            case 'x':
                xoffset = atoi(optarg);
                printf("xoffset %d\n", xoffset);
                break;
            case 'y':
                yoffset = atoi(optarg);
                printf("yoffset %d\n", yoffset);
                break;
            case 'f':
                filename = optarg;
                printf("filename %s\n", filename);
                break;
            case 'h':
            default:
                printUsage(argv);
                return -1;
                break;
        }
    }
    // Open the file for reading and writing
    fbfd = open(fbnode, O_RDWR);
    if (!fbfd) {
        printf("Error: cannot open framebuffer device.\n");
        return -2;
    }
    printf("The framebuffer device was opened successfully.\n");

    // Get fixed screen information
    if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo)) {
        printf("Error reading fixed information.\n");
        return -3;
    }

    // Get variable screen information
    if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo)) {
        printf("Error reading variable information.\n");
        return -4;
    }

    printf("%dx%d, %dbpp\n", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel);

    // Figure out the size of the screen in bytes
    screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;

    // Map the device to memory
    fbp = (unsigned char *)mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED,
                                fbfd, 0);
    if ((int)fbp == -1) {
        printf("Error: failed to map framebuffer device to memory.\n");
        return -4;
    }
    printf("The framebuffer device was mapped to memory successfully.\n");

    if (filename) {
        file_in = fopen(filename, "rb");
        if (file_in == NULL) {
            return -5;
        }
        /* get jepg size */
        fseek(file_in, 0, SEEK_END);
        jpeg_size = ftell(file_in);
        fseek(file_in, 0, SEEK_SET);
        jpeg_buf = malloc(jpeg_size);
        memset(jpeg_buf, 0, jpeg_size);
        rgb_buf = malloc(10 * 1024 * 1024);
        memset(rgb_buf, 0, 10 * 1024 * 1024);
        /* read jpeg */
        fread(jpeg_buf, jpeg_size, 1, file_in);
        fclose(file_in);
        //JPEG_JPGData_To_RGB24Data(jpeg_buf, jpeg_size, rgb_buf, &jpeg_width, &jpeg_height);
        /* convert RGB to ARGB */
        for (i = 0; i < jpeg_height; i++) {
            for (j = 0; j < jpeg_width; j++) {
                fbp[(i * jpeg_width + j) * 4] =  rgb_buf[(i * jpeg_width + j) * 3 + 2];
                fbp[(i * jpeg_width + j) * 4 + 1] =  rgb_buf[(i * jpeg_width + j) * 3 + 1];
                fbp[(i * jpeg_width + j) * 4 + 2] =  rgb_buf[(i * jpeg_width + j) * 3];
            }
        }
    } else {
        pattern_gen_cbar_v_argb(fbp, vinfo.xres, vinfo.yres);
    }

    /* wait 30s, then exit */
    sleep(30);
    if (jpeg_buf) {
        free(jpeg_buf);
    }
    if (rgb_buf) {
        free(rgb_buf);
    }
    munmap(fbp, screensize);
    close(fbfd);
    return 0;
}

       I can see a perfect colorbar with HDMI monitor,

        but the VGA's timming looks like incorrect, the picture position will change when I disable then enable the corresponding display.

       echo 0 > /sys/devices/platform/vpss/display3/enabled

       echo 1 > /sys/devices/platform/vpss/display3/enabled

      Please help me to double check it, I enable the VGA with the following step.

      A.  insmod  kernel mode with following parameters

         insmod ./kermod/vpss.ko mode=hdcomp:1080p-60 i2c_mode=1 sbufaddr=${HDVPSS_SHARED_MEM}
         insmod ./kermod/ti81xxfb.ko vram=0:8M,1:8M,2:4M
         insmod ./kermod/ti81xxhdmi.ko

      B.  Check the frambuffer parameter

# ./fbset -s -fb /dev/fb0

mode "1920x1080-60"
    # D: 148.500 MHz, H: 67.500 kHz, V: 60.000 Hz
    geometry 1920 1080 1920 1080 32
    timings 6734 148 88 36 4 44 5
    rgba 8/16,8/8,8/0,8/24
endmode

# ./fbset -s -fb /dev/fb1

mode "1920x1080-60"
    # D: 148.500 MHz, H: 67.500 kHz, V: 60.000 Hz
    geometry 1920 1080 1920 1080 32
    timings 6734 148 88 36 4 44 5
    rgba 8/16,8/8,8/0,8/24
endmode

#

C.  Check the Display parameters

# cat /sys/devices/platform/vpss/display3/mode
1080p-60
# cat /sys/devices/platform/vpss/display3/output
component,yuv422spuv
# cat /sys/devices/platform/vpss/display3/name
hdcomp
# cat /sys/devices/platform/vpss/display3/timings
148500,1920/88/148/44,1080/4/36/5,1
# cat /sys/devices/platform/vpss/display3/clksrc
aclk
# cat /sys/devices/platform/vpss/display3/enabled
1
#

D.  config the setting by myself     

      echo 0 > /sys/devices/platform/vpss/display3/enabled
      echo 1080p-60 > /sys/devices/platform/vpss/display3/mode
      echo 148500,1920/88/148/44,1080/4/36/5,1 > /sys/devices/platform/vpss/display3/timings
      echo vga,rgb888 > /sys/devices/platform/vpss/display3/output
      echo 1 > /sys/devices/platform/vpss/display3/enabled
      fbset -fb /dev/fb1 -xres 1920 -yres 1080 -vxres 1920 -vyres 1080

E.   run my test program to draw vertical colorbar

               test_fb_api -d /dev/fb1

          Any suggestions?

          BR

 

  • Hello,

    What is the software release that you are using here?
    What is the silicon version are you using?

    Best Regards,
    Margarita
  • Hi, Margarita,
    DVRRDK_04.01.00.02 is my workspace. Thanks!

    I had add my board's schematic.    It looks like AN9 and AM9 are the correct pin for HSYNC and VSYNC? 

    I had dumped the mux settings with the kernel debug fs

    # cat /sys/kernel/debug/omap_mux/tsi7_data
    name: tsi7_data.vout0_vsync (0x48140890/0x890 = 0x0001), b NA, t NA
    mode: TI816X_PIN_PULL_DOWN | TI81XX_MUX_MODE1
    signals: tsi7_data | vout0_vsync | NA | NA | NA | NA | NA | NA
    # cat /sys/kernel/debug/omap_mux/tsi7_dclk
    name: tsi7_dclk.vout0_hsync (0x4814088c/0x88c = 0x0001), b NA, t NA
    mode: TI816X_PIN_PULL_DOWN | TI81XX_MUX_MODE1
    signals: tsi7_dclk | vout0_hsync | NA | NA | NA | NA | NA | NA
    # cat /sys/kernel/debug/omap_mux/tsi7_bytstrt
    name: tsi7_bytstrt.vout0_fld (0x48140894/0x894 = 0x0001), b NA, t NA
    mode: TI816X_PIN_PULL_DOWN | TI81XX_MUX_MODE1
    signals: tsi7_bytstrt | vout0_fld | NA | NA | NA | NA | NA | NA
    # cat /sys/kernel/debug/omap_mux/tsi7_pacval
    name: tsi7_pacval.vout0_avid (0x48140898/0x898 = 0x0001), b NA, t NA
    mode: TI816X_PIN_PULL_DOWN | TI81XX_MUX_MODE1
    signals: tsi7_pacval | vout0_avid | NA | NA | NA | NA | NA | NA
    #

  • Hello,

    For DVR RDK support contact your local FAE.

    Best Regards,
    Margarita