projects
/
platform
/
framework
/
web
/
livebox-viewer.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Interface to provider is changed
[platform/framework/web/livebox-viewer.git]
/
src
/
fb.c
diff --git
a/src/fb.c
b/src/fb.c
index
1e687ef
..
13f6658
100644
(file)
--- a/
src/fb.c
+++ b/
src/fb.c
@@
-1,11
+1,11
@@
/*
/*
- * Copyright 201
2
Samsung Electronics Co., Ltd
+ * Copyright 201
3
Samsung Electronics Co., Ltd
*
*
- * Licensed under the Flora License, Version 1.
0
(the "License");
+ * Licensed under the Flora License, Version 1.
1
(the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://
www.tizenopensource.org/license
+ * http://
floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@
-32,6
+32,7
@@
#include <X11/Xutil.h>
#include <dlog.h>
#include <X11/Xutil.h>
#include <dlog.h>
+#include <livebox-errno.h> /* For error code */
#include "debug.h"
#include "util.h"
#include "debug.h"
#include "util.h"
@@
-53,7
+54,7
@@
struct fb_info {
struct buffer { /*!< Must has to be sync with slave & provider */
enum {
CREATED = 0x00beef00,
struct buffer { /*!< Must has to be sync with slave & provider */
enum {
CREATED = 0x00beef00,
- DESTROYED = 0x00dead00
,
+ DESTROYED = 0x00dead00
} state;
enum buffer_type type;
int refcnt;
} state;
enum buffer_type type;
int refcnt;
@@
-112,17
+113,18
@@
static inline int sync_for_file(struct fb_info *info)
buffer = info->buffer;
buffer = info->buffer;
- if (!buffer) /* Ignore this sync request */
- return 0;
+ if (!buffer) { /* Ignore this sync request */
+ return LB_STATUS_SUCCESS;
+ }
if (buffer->state != CREATED) {
ErrPrint("Invalid state of a FB\n");
if (buffer->state != CREATED) {
ErrPrint("Invalid state of a FB\n");
- return
-EINVAL
;
+ return
LB_STATUS_ERROR_INVALID
;
}
if (buffer->type != BUFFER_TYPE_FILE) {
}
if (buffer->type != BUFFER_TYPE_FILE) {
-
Dbg
Print("Invalid buffer\n");
- return
0
;
+
Err
Print("Invalid buffer\n");
+ return
LB_STATUS_SUCCESS
;
}
fd = open(util_uri_to_path(info->id), O_RDONLY);
}
fd = open(util_uri_to_path(info->id), O_RDONLY);
@@
-137,12
+139,14
@@
static inline int sync_for_file(struct fb_info *info)
*
* and then update it after it gots update events
*/
*
* and then update it after it gots update events
*/
- return
0
;
+ return
LB_STATUS_SUCCESS
;
}
if (read(fd, buffer->data, info->bufsz) != info->bufsz) {
ErrPrint("read: %s\n", strerror(errno));
}
if (read(fd, buffer->data, info->bufsz) != info->bufsz) {
ErrPrint("read: %s\n", strerror(errno));
- close(fd);
+ if (close(fd) < 0) {
+ ErrPrint("close: %s\n", strerror(errno));
+ }
/*!
* \note
/*!
* \note
@@
-151,11
+155,13
@@
static inline int sync_for_file(struct fb_info *info)
*
* and then update it after it gots update events
*/
*
* and then update it after it gots update events
*/
- return
0
;
+ return
LB_STATUS_SUCCESS
;
}
}
- close(fd);
- return 0;
+ if (close(fd) < 0) {
+ ErrPrint("close: %s\n", strerror(errno));
+ }
+ return LB_STATUS_SUCCESS;
}
static inline __attribute__((always_inline)) int sync_for_pixmap(struct fb_info *info)
}
static inline __attribute__((always_inline)) int sync_for_pixmap(struct fb_info *info)
@@
-165,17
+171,18
@@
static inline __attribute__((always_inline)) int sync_for_pixmap(struct fb_info
XImage *xim;
buffer = info->buffer;
XImage *xim;
buffer = info->buffer;
- if (!buffer) /*!< Ignore this sync request */
- return 0;
+ if (!buffer) { /*!< Ignore this sync request */
+ return LB_STATUS_SUCCESS;
+ }
if (buffer->state != CREATED) {
ErrPrint("Invalid state of a FB\n");
if (buffer->state != CREATED) {
ErrPrint("Invalid state of a FB\n");
- return
-EINVAL
;
+ return
LB_STATUS_ERROR_INVALID
;
}
if (buffer->type != BUFFER_TYPE_PIXMAP) {
}
if (buffer->type != BUFFER_TYPE_PIXMAP) {
-
Dbg
Print("Invalid buffer\n");
- return
0
;
+
Err
Print("Invalid buffer\n");
+ return
LB_STATUS_SUCCESS
;
}
if (!s_info.disp) {
}
if (!s_info.disp) {
@@
-191,34
+198,34
@@
static inline __attribute__((always_inline)) int sync_for_pixmap(struct fb_info
s_info.visual = DefaultVisualOfScreen(screen);
} else {
ErrPrint("Failed to open a display\n");
s_info.visual = DefaultVisualOfScreen(screen);
} else {
ErrPrint("Failed to open a display\n");
- return
-E
FAULT;
+ return
LB_STATUS_ERROR_
FAULT;
}
}
if (info->handle == 0) {
}
}
if (info->handle == 0) {
-
Dbg
Print("Pixmap ID is not valid\n");
- return
-EINVAL
;
+
Err
Print("Pixmap ID is not valid\n");
+ return
LB_STATUS_ERROR_INVALID
;
}
if (info->bufsz == 0) {
DbgPrint("Nothing can be sync\n");
}
if (info->bufsz == 0) {
DbgPrint("Nothing can be sync\n");
- return
0
;
+ return
LB_STATUS_SUCCESS
;
}
si.shmid = shmget(IPC_PRIVATE, info->bufsz, IPC_CREAT | 0666);
if (si.shmid < 0) {
ErrPrint("shmget: %s\n", strerror(errno));
}
si.shmid = shmget(IPC_PRIVATE, info->bufsz, IPC_CREAT | 0666);
if (si.shmid < 0) {
ErrPrint("shmget: %s\n", strerror(errno));
- return
-E
FAULT;
+ return
LB_STATUS_ERROR_
FAULT;
}
si.readOnly = False;
si.shmaddr = shmat(si.shmid, NULL, 0);
if (si.shmaddr == (void *)-1) {
}
si.readOnly = False;
si.shmaddr = shmat(si.shmid, NULL, 0);
if (si.shmaddr == (void *)-1) {
-
- if (shmctl(si.shmid, IPC_RMID, 0) < 0)
+ if (shmctl(si.shmid, IPC_RMID, 0) < 0) {
ErrPrint("shmctl: %s\n", strerror(errno));
ErrPrint("shmctl: %s\n", strerror(errno));
+ }
- return
-E
FAULT;
+ return
LB_STATUS_ERROR_
FAULT;
}
/*!
}
/*!
@@
-226,17
+233,19
@@
static inline __attribute__((always_inline)) int sync_for_pixmap(struct fb_info
* Use the 24 bits Pixmap for Video player
*/
xim = XShmCreateImage(s_info.disp, s_info.visual,
* Use the 24 bits Pixmap for Video player
*/
xim = XShmCreateImage(s_info.disp, s_info.visual,
-
24 /* (s_info.depth << 3) */
, ZPixmap, NULL,
+
(s_info.depth << 3)
, ZPixmap, NULL,
&si,
info->w, info->h);
if (xim == NULL) {
&si,
info->w, info->h);
if (xim == NULL) {
- if (shmdt(si.shmaddr) < 0)
+ if (shmdt(si.shmaddr) < 0)
{
ErrPrint("shmdt: %s\n", strerror(errno));
ErrPrint("shmdt: %s\n", strerror(errno));
+ }
- if (shmctl(si.shmid, IPC_RMID, 0) < 0)
+ if (shmctl(si.shmid, IPC_RMID, 0) < 0)
{
ErrPrint("shmctl: %s\n", strerror(errno));
ErrPrint("shmctl: %s\n", strerror(errno));
+ }
- return
-E
FAULT;
+ return
LB_STATUS_ERROR_
FAULT;
}
xim->data = si.shmaddr;
}
xim->data = si.shmaddr;
@@
-250,25
+259,27
@@
static inline __attribute__((always_inline)) int sync_for_pixmap(struct fb_info
XShmDetach(s_info.disp, &si);
XDestroyImage(xim);
XShmDetach(s_info.disp, &si);
XDestroyImage(xim);
- if (shmdt(si.shmaddr) < 0)
+ if (shmdt(si.shmaddr) < 0)
{
ErrPrint("shmdt: %s\n", strerror(errno));
ErrPrint("shmdt: %s\n", strerror(errno));
+ }
- if (shmctl(si.shmid, IPC_RMID, 0) < 0)
+ if (shmctl(si.shmid, IPC_RMID, 0) < 0)
{
ErrPrint("shmctl: %s\n", strerror(errno));
ErrPrint("shmctl: %s\n", strerror(errno));
+ }
- return
0
;
+ return
LB_STATUS_SUCCESS
;
}
int fb_sync(struct fb_info *info)
{
if (!info) {
ErrPrint("FB Handle is not valid\n");
}
int fb_sync(struct fb_info *info)
{
if (!info) {
ErrPrint("FB Handle is not valid\n");
- return
-EINVAL
;
+ return
LB_STATUS_ERROR_INVALID
;
}
if (!info->id || info->id[0] == '\0') {
DbgPrint("Ingore sync\n");
}
if (!info->id || info->id[0] == '\0') {
DbgPrint("Ingore sync\n");
- return
0
;
+ return
LB_STATUS_SUCCESS
;
}
if (!strncasecmp(info->id, SCHEMA_FILE, strlen(SCHEMA_FILE))) {
}
if (!strncasecmp(info->id, SCHEMA_FILE, strlen(SCHEMA_FILE))) {
@@
-277,10
+288,10
@@
int fb_sync(struct fb_info *info)
return sync_for_pixmap(info);
} else if (!strncasecmp(info->id, SCHEMA_SHM, strlen(SCHEMA_SHM))) {
/* No need to do sync */
return sync_for_pixmap(info);
} else if (!strncasecmp(info->id, SCHEMA_SHM, strlen(SCHEMA_SHM))) {
/* No need to do sync */
- return
0
;
+ return
LB_STATUS_SUCCESS
;
}
}
- return
-EINVAL
;
+ return
LB_STATUS_ERROR_INVALID
;
}
struct fb_info *fb_create(const char *id, int w, int h)
}
struct fb_info *fb_create(const char *id, int w, int h)
@@
-310,7
+321,7
@@
struct fb_info *fb_create(const char *id, int w, int h)
} else if (sscanf(info->id, SCHEMA_PIXMAP "%d", &info->handle) == 1) {
DbgPrint("PIXMAP-SHMID: %d is gotten\n", info->handle);
} else {
} else if (sscanf(info->id, SCHEMA_PIXMAP "%d", &info->handle) == 1) {
DbgPrint("PIXMAP-SHMID: %d is gotten\n", info->handle);
} else {
- info->handle =
-EINVAL
;
+ info->handle =
LB_STATUS_ERROR_INVALID
;
}
info->bufsz = 0;
}
info->bufsz = 0;
@@
-325,7
+336,7
@@
int fb_destroy(struct fb_info *info)
{
if (!info) {
ErrPrint("Handle is not valid\n");
{
if (!info) {
ErrPrint("Handle is not valid\n");
- return
-EINVAL
;
+ return
LB_STATUS_ERROR_INVALID
;
}
if (info->buffer) {
}
if (info->buffer) {
@@
-337,7
+348,7
@@
int fb_destroy(struct fb_info *info)
free(info->id);
free(info);
free(info->id);
free(info);
- return
0
;
+ return
LB_STATUS_SUCCESS
;
}
int fb_is_created(struct fb_info *info)
}
int fb_is_created(struct fb_info *info)
@@
-446,7
+457,7
@@
int fb_release_buffer(void *data)
struct buffer *buffer;
if (!data) {
struct buffer *buffer;
if (!data) {
-
Dbg
Print("buffer data == NIL\n");
+
Err
Print("buffer data == NIL\n");
return 0;
}
return 0;
}
@@
-454,13
+465,14
@@
int fb_release_buffer(void *data)
if (buffer->state != CREATED) {
ErrPrint("Invalid handle\n");
if (buffer->state != CREATED) {
ErrPrint("Invalid handle\n");
- return
-EINVAL
;
+ return
LB_STATUS_ERROR_INVALID
;
}
switch (buffer->type) {
case BUFFER_TYPE_SHM:
}
switch (buffer->type) {
case BUFFER_TYPE_SHM:
- if (shmdt(buffer) < 0)
+ if (shmdt(buffer) < 0)
{
ErrPrint("shmdt: %s\n", strerror(errno));
ErrPrint("shmdt: %s\n", strerror(errno));
+ }
break;
case BUFFER_TYPE_PIXMAP:
buffer->refcnt--;
break;
case BUFFER_TYPE_PIXMAP:
buffer->refcnt--;
@@
-471,8
+483,9
@@
int fb_release_buffer(void *data)
buffer->state = DESTROYED;
free(buffer);
buffer->state = DESTROYED;
free(buffer);
- if (info && info->buffer == buffer)
+ if (info && info->buffer == buffer)
{
info->buffer = NULL;
info->buffer = NULL;
+ }
}
break;
case BUFFER_TYPE_FILE:
}
break;
case BUFFER_TYPE_FILE:
@@
-484,8
+497,9
@@
int fb_release_buffer(void *data)
buffer->state = DESTROYED;
free(buffer);
buffer->state = DESTROYED;
free(buffer);
- if (info && info->buffer == buffer)
+ if (info && info->buffer == buffer)
{
info->buffer = NULL;
info->buffer = NULL;
+ }
}
break;
default:
}
break;
default:
@@
-502,21
+516,22
@@
int fb_refcnt(void *data)
struct shmid_ds buf;
int ret;
struct shmid_ds buf;
int ret;
- if (!data)
- return -EINVAL;
+ if (!data) {
+ return LB_STATUS_ERROR_INVALID;
+ }
buffer = container_of(data, struct buffer, data);
if (buffer->state != CREATED) {
ErrPrint("Invalid handle\n");
buffer = container_of(data, struct buffer, data);
if (buffer->state != CREATED) {
ErrPrint("Invalid handle\n");
- return
-EINVAL
;
+ return
LB_STATUS_ERROR_INVALID
;
}
switch (buffer->type) {
case BUFFER_TYPE_SHM:
if (shmctl(buffer->refcnt, IPC_STAT, &buf) < 0) {
ErrPrint("Error: %s\n", strerror(errno));
}
switch (buffer->type) {
case BUFFER_TYPE_SHM:
if (shmctl(buffer->refcnt, IPC_STAT, &buf) < 0) {
ErrPrint("Error: %s\n", strerror(errno));
- return
-E
FAULT;
+ return
LB_STATUS_ERROR_
FAULT;
}
ret = buf.shm_nattch;
}
ret = buf.shm_nattch;
@@
-528,7
+543,7
@@
int fb_refcnt(void *data)
ret = buffer->refcnt;
break;
default:
ret = buffer->refcnt;
break;
default:
- ret =
-EINVAL
;
+ ret =
LB_STATUS_ERROR_INVALID
;
break;
}
break;
}
@@
-544,18
+559,22
@@
int fb_get_size(struct fb_info *info, int *w, int *h)
{
if (!info) {
ErrPrint("Handle is not valid\n");
{
if (!info) {
ErrPrint("Handle is not valid\n");
- return
-EINVAL
;
+ return
LB_STATUS_ERROR_INVALID
;
}
*w = info->w;
*h = info->h;
}
*w = info->w;
*h = info->h;
- return
0
;
+ return
LB_STATUS_SUCCESS
;
}
int fb_size(struct fb_info *info)
{
}
int fb_size(struct fb_info *info)
{
+ if (!info) {
+ return 0;
+ }
+
info->bufsz = info->w * info->h * s_info.depth;
info->bufsz = info->w * info->h * s_info.depth;
- return info
? info->bufsz : 0
;
+ return info
->bufsz
;
}
/* End of a file */
}
/* End of a file */