Add code to open a drm device

Signed-off-by: Chris Michael <cp.michael@samsung.com>
This commit is contained in:
Chris Michael 2013-12-20 14:05:26 +00:00
parent 6c6aef928c
commit 845994c441
1 changed files with 18 additions and 1 deletions

View File

@ -18,6 +18,8 @@
#include <Eina.h>
#include <Ecore_Drm.h>
static int _send_msg(int opcode, int fd, void *data, size_t bytes);
static struct cmsghdr *cmsgptr = NULL;
static int _read_fd = -1;
static int _write_fd = -1;
@ -39,6 +41,20 @@ static int _write_fd = -1;
(_iov)->iov_base = (void *)(_addr); \
(_iov)->iov_len = (_len);
static int
_open_device(const char *device)
{
int fd = -1, ret = ECORE_DRM_OP_SUCCESS;
if ((fd = open(device, O_RDWR)) < 0)
{
fprintf(stderr, "Failed to open device: %s: %m\n", device);
ret = ECORE_DRM_OP_FAILURE;
}
return ret;
}
static int
_read_fd_get(void)
{
@ -139,7 +155,7 @@ _send_msg(int opcode, int fd, void *data, size_t bytes)
static int
_recv_msg(void)
{
/* int ret = -1; */
int ret = -1;
Ecore_Drm_Message dmsg;
struct iovec iov[2];
struct msghdr msg;
@ -193,6 +209,7 @@ _recv_msg(void)
{
case ECORE_DRM_OP_DEVICE_OPEN:
fprintf(stderr, "Open Device: %s\n", (char *)data);
ret = _open_device((char *)data);
break;
default:
fprintf(stderr, "Unhandled Opcode: %d\n", dmsg.opcode);