forked from torvalds/linux
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* introduce some version macros to the ioctl header. * introduce a new versioning ioctl. * pr_info the version on load. * verbosely warn when user application is not using the version ioctl before doing anything else with /dev/disp * verbosely warn about the bumpy road ahead, and point to the wiki when doing so. Signed-off-by: Luc Verhaegen <libv@skynet.be>
- Loading branch information
Showing
3 changed files
with
155 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Simple example to ease users of /dev/disp into using the new but mandatory | ||
* versioning handshake ioctl. No license or copyright claims made. | ||
* | ||
* Use | ||
* gcc -Wall -I../../../include -o disp_version version.c | ||
* to compile this. | ||
* | ||
* Author: Luc Verhaegen <libv@skynet.be> | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <fcntl.h> | ||
#include <sys/ioctl.h> | ||
#include <errno.h> | ||
#include <string.h> | ||
#include <asm/types.h> | ||
|
||
#include <video/sunxi_disp_ioctl.h> | ||
|
||
int | ||
main(int argc, char *argv[]) | ||
{ | ||
int fd = open("/dev/disp", O_RDWR); | ||
int ret, tmp, width, height; | ||
|
||
if (fd == -1) { | ||
fprintf(stderr, "Error: Failed to open /dev/mali: %s\n", | ||
strerror(errno)); | ||
return errno; | ||
} | ||
|
||
tmp = SUNXI_DISP_VERSION; | ||
ret = ioctl(fd, DISP_CMD_VERSION, &tmp); | ||
if (ret < 0) { | ||
fprintf(stderr, "Error: ioctl(VERSION) failed: %s\n", | ||
strerror(-ret)); | ||
return ret; | ||
} | ||
|
||
printf("disp kernel module version is %d.%d\n", | ||
ret >> 16, ret & 0xFFFF); | ||
|
||
tmp = 0; | ||
ret = ioctl(fd, DISP_CMD_SCN_GET_WIDTH, &tmp); | ||
if (ret) { | ||
fprintf(stderr, "Error: ioctl(SCN_GET_WIDTH) failed: %s\n", | ||
strerror(ret)); | ||
return ret; | ||
} | ||
|
||
width = ret; | ||
|
||
tmp = 0; | ||
ret = ioctl(fd, DISP_CMD_SCN_GET_HEIGHT, &tmp); | ||
if (ret) { | ||
fprintf(stderr, "Error: ioctl(SCN_GET_HEIGHT) failed: %s\n", | ||
strerror(ret)); | ||
return ret; | ||
} | ||
|
||
height = ret; | ||
|
||
printf("DISP dimensions are %dx%d\n", width, height); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters