ioctl(fd, FBIOGET_VSCREENINFO, &varInfo) == -1) {
ERR("Failed FBIOGET_VSCREENINFO on %s (%s)\n", FBVID_DEVICE,
strerror(errno));
return FAILURE;
}
if (ioctl(fd, FBIOGET_FSCREENINFO, &finfo) == -1) {
ERR("Failed FBIOGET_FSCREENINFO on %s (%s)\n", FBVID_DEVICE,
strerror(errno));
return FAILURE;
}
hi
please tell me what they mean for FBIOGET_VSCREENINFO and FBIOGET_FSCREENINFO?
source material as follows:
main.c
*
* ============================================================================
* Copyright (c) Texas Instruments Inc 2007
*
* Use of this software is controlled by the terms and conditions found in the
* license agreement under which this software has been supplied or provided.
* ============================================================================
*/
/* Standard Linux headers */
#include <stdio>#include <stdlib>#include <getopt>#include <unistd>#include <string>#include <errno>#include <sys>#include <sys>#include <sys>#include <sys>#include <fcntl>#include <linux>/* Davinci specific kernel headers */
#include <video/davincifb_ioctl.h>
/* Demo headers */
#include "interface.h"
/* The levels of initialization */
#define SCREENINITIALIZED 0x1
/* Video window to show diagram on */
#define FBVID_DEVICE "/dev/fb/3"
#define OSD_DEVICE "/dev/fb/0"
#define ATTR_DEVICE "/dev/fb/2"
#define UYVY_BLACK 0x10801080
#define D1RESOLUTIONSTRINGPAL "720x576"
#define D1RESOLUTIONSTRINGNTSC "720x480"
#define CIFRESOLUTIONSTRINGPAL "352x288"
#define CIFRESOLUTIONSTRINGNTSC "352x240"
/* Add argument number x of string y */
#define addArg(x, y) \
argv[(x)] = malloc(strlen((y)) + 1); \
if (argv[(x)] == NULL) \
return FAILURE; \
strcpy(argv[(x)++], (y))
enum StartLevels {
START_BEGINNING,
START_MENU,
START_ENCODEDECODE,
START_ENCODE,
START_DECODE,
NUM_START_LEVELS
};
/* Global variable declarations for this application */
GlobalData gbl = { NULL, NOSTD };
static enum StartLevels startLevel = START_BEGINNING;
static int launch = FALSE;
/******************************************************************************
* drawDiagram
******************************************************************************/
int drawDiagram(char *diagram)
{
struct fb_var_screeninfo varInfo;
struct fb_fix_screeninfo finfo;
int fd;
int size;
int i;
int fileFd;
int numBytes;
char *src, *srcPtr;
char *dst, *dstPtr;
int lineSize;
fd = open(FBVID_DEVICE, O_RDWR);
if (fd == -1) {
ERR("Failed to open fb device %s (%s)\n", FBVID_DEVICE,
strerror(errno));
return FAILURE;
}
if (ioctl(fd, FBIOGET_VSCREENINFO, &varInfo) == -1) {
ERR("Failed FBIOGET_VSCREENINFO on %s (%s)\n", FBVID_DEVICE,
strerror(errno));
return FAILURE;
}
if (ioctl(fd, FBIOGET_FSCREENINFO, &finfo) == -1) {
ERR("Failed FBIOGET_FSCREENINFO on %s (%s)\n", FBVID_DEVICE,
strerror(errno));
return FAILURE;
}
varInfo.yoffset = 0;
/* Swap the working buffer for the displayed buffer */
if (ioctl(fd, FBIOPAN_DISPLAY, &varInfo) == -1) {
ERR("Failed FBIOPAN_DISPLAY (%s)\n", strerror(errno));
return FAILURE;
}
dst = (char *) mmap (NULL,
varInfo.yres_virtual * finfo.line_length,
PROT_READ | PROT_WRITE,
MAP_SHARED,
fd, 0);
/* Map the video buffer to user space */
if (dst == MAP_FAILED) {
ERR("Failed mmap on %s (%s)\n", FBVID_DEVICE, strerror(errno));
return FAILURE;
}
varInfo.xres = SCREEN_WIDTH;
varInfo.yres = SCREEN_HEIGHT;
varInfo.yres_virtual = NUM_OSD_BUFS * SCREEN_HEIGHT;
varInfo.bits_per_pixel = SCREEN_BPP;
/* Set video display format */
if (ioctl(fd, FBIOPUT_VSCREENINFO, &varInfo) == -1) {
ERR("Failed FBIOPUT_VSCREENINFO on %s (%s)\n", FBVID_DEVICE,
strerror(errno));
return FAILURE;
}
if (varInfo.xres != SCREEN_WIDTH ||
varInfo.yres != SCREEN_HEIGHT ||
varInfo.bits_per_pixel != SCREEN_BPP) {
ERR("Failed to get the requested screen size: %dx%d at %d bpp\n",
SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP);
return FAILURE;
}
size = varInfo.xres * varInfo.yres * varInfo.bits_per_pixel / 8;
fileFd = open(diagram, O_RDONLY);
if (fileFd == -1) {
ERR("Failed to open demo diagram file (%s)\n", strerror(errno));
return FAILURE;
}
src = malloc(size);
if (src == NULL) {
ERR("Failed to allocate memory for diagram\n");
return FAILURE;
}
numBytes = read(fileFd, src, size);
if (numBytes != size) {
ERR("Error reading data from diagram file (%s)\n", strerror(errno));
return FAILURE;
}
srcPtr = src;
dstPtr = dst;
lineSize = (varInfo.xres * varInfo.bits_per_pixel) / 8;
for (i = 0; i < varInfo.yres; i++) {
memcpy(dstPtr, srcPtr, lineSize);
srcPtr += lineSize;
dstPtr += finfo.line_length;
}
free(src);
munmap(dst, varInfo.yres_virtual * finfo.line_length);
close(fd);
close(fileFd);
return SUCCESS;
}
/******************************************************************************
* screenInit
******************************************************************************/
static int screenInit(void)
{
struct fb_var_screeninfo varInfo;
int fd;
unsigned short *display;
FILE * fp;
char mode[16];
int status = FAILURE;
fd = open(OSD_DEVICE, O_RDWR);
if (fd == -1) {
ERR("Failed to open fb device %s\n", OSD_DEVICE);
return FAILURE;
}
if (ioctl(fd, FBIOGET_VSCREENINFO, &varInfo) == -1) {
ERR("Failed ioctl FBIOGET_VSCREENINFO on %s\n", OSD_DEVICE);
return FAILURE;
}
if (ioctl(fd, FBIOGET_VSCREENINFO, &varInfo) == -1) {
ERR("Failed ioctl FBIOGET_VSCREENINFO on %s\n", OSD_DEVICE);
return FAILURE;
}
if ((fp = fopen("/sys/class/davinci_display/ch0/mode", "r")) != NULL) {
fscanf(fp, "%s", mode);
fclose(fp);
if (strcmp(mode, "NTSC") == 0) {
DBG("NTSC selected\n");
gbl.yFactor = NTSCSTD;
status = SUCCESS;
}
else if (strcmp(mode, "PAL") == 0) {
DBG("PAL selected\n");
gbl.yFactor = PALSTD;
status = SUCCESS;
}
}
/* Try the requested size */
varInfo.xres = SCREEN_WIDTH;
varInfo.yres = SCREEN_HEIGHT;
varInfo.yres_virtual = NUM_OSD_BUFS * SCREEN_HEIGHT;
varInfo.bits_per_pixel = SCREEN_BPP;
if (ioctl(fd, FBIOPUT_VSCREENINFO, &varInfo) == -1) {
ERR("Failed ioctl FBIOPUT_VSCREENINFO on %s\n", OSD_DEVICE);
return FAILURE;
}
if (varInfo.xres != SCREEN_WIDTH ||
varInfo.yres != SCREEN_HEIGHT ||
varInfo.bits_per_pixel != SCREEN_BPP) {
ERR("Failed to get the requested screen size: %dx%d at %d bpp\n",
SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP);
}
display = (unsigned short *) mmap(NULL, SCREEN_SIZE, PROT_READ | PROT_WRITE,
MAP_SHARED, fd, 0);
if (display == MAP_FAILED) {
ERR("Failed mmap on %s\n", OSD_DEVICE);
return FAILURE;
}
gbl.display = display;
return fd;
}Add a code snippet to your website: www.paste.org