summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPer Persson <per.xb.persson@stericsson.com>2011-07-04 10:19:53 +0200
committerJimmy RUBIN <jimmy.rubin@stericsson.com>2011-07-05 10:02:30 +0200
commitf5784d2722df6d09dcf09f13a316531bf80fa973 (patch)
tree456720a1e992d08c0ff3e36df49211b7e2f2c125
parent23362b8dfcd202b097c48753f6167b428818ca53 (diff)
HDMIservice: Prepare for lbp build
Makefile for building lbp is added. Compiler warnings are removed. ST-Ericsson ID: 350562 ST-Ericsson FOSS-OUT ID: STETL-FOSS-OUT-10177 Change-Id: I32dd6de5eeaedb0a9aaae7dfb3f0dc0713c8e2d5 Signed-off-by: Per Persson <per.xb.persson@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/26488 Reviewed-by: QATEST Reviewed-by: QATOOLS Reviewed-by: Robert LIND <robert.lind@stericsson.com> Reviewed-by: Jimmy RUBIN <jimmy.rubin@stericsson.com>
-rw-r--r--Makefile34
-rw-r--r--include/hdmi_service_local.h13
-rw-r--r--src/cec.c10
-rw-r--r--src/edid.c19
-rw-r--r--src/hdcp.c10
-rw-r--r--src/hdmi_service.c33
-rw-r--r--src/hdmi_service_api.c1
-rw-r--r--src/hdmi_service_start.c1
-rw-r--r--src/kevent.c9
-rw-r--r--src/setres.c4
-rw-r--r--src/socket.c12
11 files changed, 104 insertions, 42 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..30cccb0
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,34 @@
+# Makefile for HDMIservice
+#
+# Copyright (C) ST-Ericsson AB 2011.
+#
+
+PACKAGE_NAME=hdmi_service
+
+CFLAGS += -c -Wall -O2 -fPIC
+LDFLAGS += -L./ -lpthread -shared
+LDFLAGS_2 = -L./
+INCLUDES += -I./include
+HDMILIBS = hdmiservice.so
+
+build: hdmiservice.so hdmistart
+
+install: clean build
+ @$(PACKAGE_FILE) /usr/lib/hdmiservice.so $(CURDIR)/hdmiservice.so 755 0 0
+ @$(PACKAGE_FILE) /usr/bin/hdmistart $(CURDIR)/hdmistart 755 0 0
+
+%.o: src/%.c
+ ${CC} ${CFLAGS} ${INCLUDES} -c $<
+
+hdmiservice.so: cec.o edid.o hdcp.o hdmi_service_api.o hdmi_service.o kevent.o \
+ setres.o socket.o
+ $(CC) $(LDFLAGS) $^ -o $@
+
+hdmistart: hdmi_service_start.o
+ $(CC) $(LDFLAGS_2) $^ -o $@ $(HDMILIBS)
+
+clean:
+ @rm -rf cec.o edid.o hdcp.o hdmi_service_api.o hdmi_service.o kevent.o \
+ setres.o socket.o hdmiservice.so hdmi_service_start.o hdmistart
+
+.PHONY: hdmiservice.so clean
diff --git a/include/hdmi_service_local.h b/include/hdmi_service_local.h
index bba6812..651dd40 100644
--- a/include/hdmi_service_local.h
+++ b/include/hdmi_service_local.h
@@ -131,17 +131,24 @@ int hdmi_service_vesa_cea_prio_set(__u8 vesa_cea1, __u8 nr1,
#define true 1
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+#ifdef ANDROID
+#define FBPATH "/dev/graphics/"
#define LOGHDMILIB LOGE
#define LOGHDMILIB2 LOGE
#define LOGHDMILIB3(format, ...)
-
-#ifdef ANDROID
-#define FBPATH "/dev/graphics/"
#else
#define FBPATH "/dev/"
+#define LOGHDR "libhdmi:"
+#define LOGHDMILIB(format, ...) printf(LOGHDR format"\r\n", __VA_ARGS__)
+#define LOGHDMILIB2(format, ...) printf(LOGHDR format"\r\n", __VA_ARGS__)
+#define LOGHDMILIB3(format, ...) printf(LOGHDR format"\r\n", __VA_ARGS__)
#endif
+#ifdef ANDROID
#define SOCKET_LISTEN_PATH "/dev/socket/hdmi_listen"
+#else
+#define SOCKET_LISTEN_PATH "/dev/hdmi_listen"
+#endif
#define STOREASTEXT_FILE "/sys/class/misc/hdmi/storeastext"
#define PLUGDETEN_FILE "/sys/class/misc/hdmi/plugdeten"
diff --git a/src/cec.c b/src/cec.c
index d5125d9..13bc063 100644
--- a/src/cec.c
+++ b/src/cec.c
@@ -7,6 +7,7 @@
#include <unistd.h> /* Symbolic Constants */
#include <sys/types.h> /* Primitive System Data Types */
+#include <linux/types.h>
#include <errno.h> /* Errors */
#include <stdarg.h>
#include <stdio.h> /* Input/Output */
@@ -15,7 +16,9 @@
#include <fcntl.h>
#include <time.h>
#include <ctype.h>
+#ifdef ANDROID
#include <utils/Log.h>
+#endif
#include "../include/hdmi_service_api.h"
#include "../include/hdmi_service_local.h"
@@ -37,15 +40,18 @@ static int cectxcmdid_get(void)
int cecrx_subscribe(void)
{
int cecrxfd;
+ int ret = 0;
cecrxfd = open(CECRXEVEN_FILE, O_WRONLY);
if (cecrxfd < 0) {
LOGHDMILIB(" failed to open %s", CECRXEVEN_FILE);
return -1;
}
- write(cecrxfd, cecrxeven_val, sizeof(cecrxeven_val));
+ if (write(cecrxfd, cecrxeven_val, sizeof(cecrxeven_val)) !=
+ sizeof(cecrxeven_val))
+ ret = -2;
close(cecrxfd);
- return 0;
+ return ret;
}
int cecsenderr(void)
diff --git a/src/edid.c b/src/edid.c
index adcab88..c0f0b4d 100644
--- a/src/edid.c
+++ b/src/edid.c
@@ -7,6 +7,7 @@
#include <unistd.h> /* Symbolic Constants */
#include <sys/types.h> /* Primitive System Data Types */
+#include <linux/types.h>
#include <errno.h> /* Errors */
#include <stdarg.h>
#include <stdio.h> /* Input/Output */
@@ -15,7 +16,9 @@
#include <fcntl.h>
#include <time.h>
#include <ctype.h>
+#ifdef ANDROID
#include <utils/Log.h>
+#endif
#include "../include/hdmi_service_api.h"
#include "../include/hdmi_service_local.h"
@@ -164,7 +167,6 @@ int edid_read(__u8 block, __u8 *data)
int size;
LOGHDMILIB("EDID read blk %d", block);
-
/* Request edid block 0 */
edidread = open(EDIDREAD_FILE, O_RDWR);
if (edidread < 0) {
@@ -211,7 +213,6 @@ int edid_parse0(__u8 *data, __u8 *extension, struct video_format formats[],
__u8 version;
__u8 revision;
__u8 est_timing;
- int findex;
int vesa_nr;
int bit;
int cnt;
@@ -288,10 +289,12 @@ int edid_parse0(__u8 *data, __u8 *extension, struct video_format formats[],
edidp = EDID_BL0_STDTIM1_OFFSET + index * 2;
xres = (*(data + edidp) + 31) * 8;
byte = *(data + edidp + 1);
- ar_index = (byte * EDID_STDTIM_AR_MASK) >> EDID_STDTIM_AR_SHIFT;
+ ar_index = (byte & EDID_STDTIM_AR_MASK) >> EDID_STDTIM_AR_SHIFT;
yres = xres * edid_stdtim_ar[ar_index].y /
edid_stdtim_ar[ar_index].x;
- freq = (byte * EDID_STDTIM_FREQ_MASK) >> EDID_STDTIM_FREQ_SHIFT;
+ freq = 60 + ((byte & EDID_STDTIM_FREQ_MASK) >>
+ EDID_STDTIM_FREQ_SHIFT);
+ LOGHDMILIB2("xres:%d yres:%d freq:%d", xres, yres, freq);
vesa_nr = get_vesanr_from_std_timing(xres, yres, freq);
if (vesa_nr < 1)
continue;
@@ -484,12 +487,14 @@ int edid_parse1(__u8 *data, struct video_format formats[], int nr_formats,
edidp += EDID_BL1_STDTIM9_BYTE_START + index * 2;
xres = (*(data + edidp) + 31) * 8;
byte = *(data + edidp + 1);
- ar_index = (byte * EDID_STDTIM_AR_MASK) >>
+ ar_index = (byte & EDID_STDTIM_AR_MASK) >>
EDID_STDTIM_AR_SHIFT;
yres = xres * edid_stdtim_ar[ar_index].y /
edid_stdtim_ar[ar_index].x;
- freq = (byte * EDID_STDTIM_FREQ_MASK) >>
- EDID_STDTIM_FREQ_SHIFT;
+ freq = 60 + ((byte & EDID_STDTIM_FREQ_MASK) >>
+ EDID_STDTIM_FREQ_SHIFT);
+ LOGHDMILIB2("xres:%d yres:%d freq:%d", xres, yres,
+ freq);
vesa_nr = get_vesanr_from_std_timing(xres, yres, freq);
LOGHDMILIB2("StdTim9to16 try vesa_nr:%d", vesa_nr);
for (cnt = 0; cnt < nr_formats; cnt++) {
diff --git a/src/hdcp.c b/src/hdcp.c
index 170afbb..88b67c3 100644
--- a/src/hdcp.c
+++ b/src/hdcp.c
@@ -7,6 +7,7 @@
#include <unistd.h> /* Symbolic Constants */
#include <sys/types.h> /* Primitive System Data Types */
+#include <linux/types.h>
#include <errno.h> /* Errors */
#include <stdarg.h>
#include <stdio.h> /* Input/Output */
@@ -16,7 +17,9 @@
#include <time.h>
#include <sys/ioctl.h>
#include <ctype.h>
+#ifdef ANDROID
#include <utils/Log.h>
+#endif
#include "../include/hdmi_service_api.h"
#include "../include/hdmi_service_local.h"
@@ -105,7 +108,6 @@ int hdcp_init(__u8 *aes)
int value = 0;
char buf[128];
int result = HDCP_OK;
- int events;
/* Check if OTP is fused */
hdcpchkaesotp = open(HDCPCHKAESOTP_FILE, O_RDONLY);
@@ -133,8 +135,12 @@ int hdcp_init(__u8 *aes)
result = SYSFS_FILE_FAILED;
goto hdcp_end;
}
- write(hdcpeven, hdcp_even_val, sizeof(hdcp_even_val));
+ res = write(hdcpeven, hdcp_even_val, sizeof(hdcp_even_val));
close(hdcpeven);
+ if (res != sizeof(hdcp_even_val)) {
+ result = SYSFS_FILE_FAILED;
+ goto hdcp_end;
+ }
/* Write aes keys */
hdcploadaes = open(HDCPLOADAES_FILE, O_WRONLY);
diff --git a/src/hdmi_service.c b/src/hdmi_service.c
index 6232b75..cbb88d0 100644
--- a/src/hdmi_service.c
+++ b/src/hdmi_service.c
@@ -7,6 +7,7 @@
#include <unistd.h> /* Symbolic Constants */
#include <sys/types.h> /* Primitive System Data Types */
+#include <linux/types.h>
#include <errno.h> /* Errors */
#include <stdarg.h>
#include <stdio.h> /* Input/Output */
@@ -19,7 +20,9 @@
#include <sys/ioctl.h>
#include "linux/fb.h"
#include <sys/socket.h>
+#ifdef ANDROID
#include <utils/Log.h>
+#endif
#include <dirent.h>
#include "../include/hdmi_service_api.h"
#include "../include/hdmi_service_local.h"
@@ -60,7 +63,7 @@ static int dispdevice_path_set(void)
n = scandir(DISPDEVICE_PATH_1, &namelist, 0, hdmidirsort);
if (n < 0) {
- LOGHDMILIB("scandir error");
+ LOGHDMILIB("%s", "scandir error");
return -1;
}
@@ -158,16 +161,18 @@ static int hdmievwakeupfile_wr(void)
int poweronoff(__u8 onoff)
{
int pwrfd;
+ int ret = 0;
pwrfd = open(POWERONOFF_FILE, O_WRONLY);
if (pwrfd < 0) {
LOGHDMILIB(" failed to open %s", POWERONOFF_FILE);
return -1;
}
- write(pwrfd, &onoff, 1);
+ if (write(pwrfd, &onoff, 1) != 1)
+ ret = -2;
close(pwrfd);
- return 0;
+ return ret;
}
/* Get hw power */
@@ -212,16 +217,18 @@ static int plugstate_get(enum hdmi_plug_state *plug_state)
static int hdmi_format_set(enum hdmi_format format)
{
int fd;
+ int ret = 0;
fd = dispdevice_file_open(HDMIFORMAT_FILE, O_WRONLY);
if (fd < 0) {
LOGHDMILIB(" failed to open %s", HDMIFORMAT_FILE);
return -1;
}
- write(fd, &format, 1);
+ if (write(fd, &format, 1) != 1)
+ ret = -2;
close(fd);
- return 0;
+ return ret;
}
/* Send illegal state message on client socket */
@@ -229,7 +236,6 @@ static int illegalstate_send(__u32 cmd, __u32 cmd_id)
{
int val;
__u8 buf[16];
- int sock;
val = cmd;
memcpy(&buf[CMD_OFFSET], &val, 4);
@@ -308,8 +314,6 @@ static int hdmiplugged_handle(int *basic_audio_support)
int disponoff;
char req_str[7];
int wr_res;
- int fd;
- char fbname[128];
char buf[128];
int read_res;
struct video_format *formats;
@@ -352,7 +356,6 @@ static int hdmiplugged_handle(int *basic_audio_support)
ret = -1;
goto hdmiplugged_handle_end;
}
-
if (extension) {
/* Extension data exists */
cnt = 0;
@@ -445,8 +448,6 @@ hdmiplugged_handle_end:
static int hdmiunplugged_handle(void)
{
- enum hdmi_power_state power_state;
-
LOGHDMILIB("%s", "HDMIEVENT_HDMIUNPLUGGED");
plugstate_set(HDMI_UNPLUGGED);
@@ -455,12 +456,6 @@ static int hdmiunplugged_handle(void)
return 0;
}
-static int hdmiunknownhandle(int event)
-{
- LOGHDMILIB("HDMIEVENT_EVENTUNKNOWN: %d", event);
- return 0;
-}
-
/* Close frame buffer */
static int hdmi_fb_close(void)
{
@@ -542,7 +537,6 @@ static int plugevent_send(__u32 cmd, int audio_support, int nr,
int res = 0;
int val;
__u8 buf[128];
- int sock;
__u32 cmd_id;
int cnt;
@@ -631,7 +625,6 @@ int hdmi_event(int event)
static int hdmi_eventcmd(void)
{
struct cmd_data *cmd_obj = NULL;
- struct cmd_data *del_obj;
int res = 0;
int ret = -1;
enum hdmi_power_state power_state;
@@ -1086,7 +1079,7 @@ int hdmi_service_edid_request(__u8 block)
int hdmi_service_hdcp_init(__u16 aes_size, __u8 *aes_data)
{
int val;
- __u8 buf[300];
+ __u8 buf[AES_KEYS_SIZE + CMDBUF_OFFSET];
if (aes_size != AES_KEYS_SIZE)
return -1;
diff --git a/src/hdmi_service_api.c b/src/hdmi_service_api.c
index 42edf26..37b6890 100644
--- a/src/hdmi_service_api.c
+++ b/src/hdmi_service_api.c
@@ -7,6 +7,7 @@
#include <unistd.h> /* Symbolic Constants */
#include <sys/types.h> /* Primitive System Data Types */
+#include <linux/types.h>
#include <errno.h> /* Errors */
#include <stdarg.h>
#include <stdio.h> /* Input/Output */
diff --git a/src/hdmi_service_start.c b/src/hdmi_service_start.c
index 49c0914..d7cc7f1 100644
--- a/src/hdmi_service_start.c
+++ b/src/hdmi_service_start.c
@@ -7,6 +7,7 @@
#include <unistd.h> /* Symbolic Constants */
#include <sys/types.h> /* Primitive System Data Types */
+#include <linux/types.h>
#include <errno.h> /* Errors */
#include <stdarg.h>
#include <stdio.h> /* Input/Output */
diff --git a/src/kevent.c b/src/kevent.c
index f6375c4..7d509ae 100644
--- a/src/kevent.c
+++ b/src/kevent.c
@@ -7,6 +7,7 @@
#include <unistd.h> /* Symbolic Constants */
#include <sys/types.h> /* Primitive System Data Types */
+#include <linux/types.h>
#include <errno.h> /* Errors */
#include <stdarg.h>
#include <stdio.h> /* Input/Output */
@@ -17,7 +18,9 @@
#include <time.h>
#include <ctype.h>
#include <sys/poll.h>
+#ifdef ANDROID
#include <utils/Log.h>
+#endif
#include "../include/hdmi_service_api.h"
#include "../include/hdmi_service_local.h"
@@ -90,15 +93,17 @@ static int hdmieventfile_close(int fd)
int hdmievclr(__u8 mask)
{
int evclrfd;
+ int ret = 0;
evclrfd = open(EVENTCLR_FILE, O_WRONLY);
if (evclrfd < 0) {
LOGHDMILIB(" failed to open %s", EVENTCLR_FILE);
return -1;
}
- write(evclrfd, &mask, 1);
+ if (write(evclrfd, &mask, 1) != 1)
+ ret = -2;
close(evclrfd);
- return 0;
+ return ret;
}
/*
diff --git a/src/setres.c b/src/setres.c
index a4be32f..2fa4efb 100644
--- a/src/setres.c
+++ b/src/setres.c
@@ -7,6 +7,8 @@
#include <unistd.h> /* Symbolic Constants */
#include <sys/types.h> /* Primitive System Data Types */
+#include <linux/types.h>
+#include <sys/ioctl.h>
#include <errno.h> /* Errors */
#include <stdarg.h>
#include <stdio.h> /* Input/Output */
@@ -16,7 +18,9 @@
#include <time.h>
#include <ctype.h>
#include "linux/fb.h"
+#ifdef ANDROID
#include <utils/Log.h>
+#endif
#include "../include/hdmi_service_api.h"
#include "../include/hdmi_service_local.h"
diff --git a/src/socket.c b/src/socket.c
index a677cdd..b029e11 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -7,6 +7,7 @@
#include <unistd.h> /* Symbolic Constants */
#include <sys/types.h> /* Primitive System Data Types */
+#include <linux/types.h>
#include <errno.h> /* Errors */
#include <stdarg.h>
#include <stdio.h> /* Input/Output */
@@ -18,7 +19,9 @@
#include <ctype.h>
#include <sys/socket.h>
#include <sys/un.h>
+#ifdef ANDROID
#include <utils/Log.h>
+#endif
#include "../include/hdmi_service_api.h"
#include "../include/hdmi_service_local.h"
@@ -54,7 +57,7 @@ int clientsocket_get(void)
}
/* Client socket thread. Handles incoming socket messages */
-static void thread_sockclient_fn(void *arg)
+static void thread_sockclient_fn(int *arg)
{
int bytes = 0;
char buffer[SOCKET_DATA_MAX];
@@ -65,7 +68,7 @@ static void thread_sockclient_fn(void *arg)
LOGHDMILIB("%s begin", __func__);
- sock = (int)arg;
+ sock = *arg;
clientsocket_set(sock);
LOGHDMILIB("clisock:%d", sock);
@@ -154,8 +157,6 @@ void thread_socklisten_fn(void *arg)
struct sockaddr_un serv_addr;
struct sockaddr_un cli_addr;
int res;
- fd_set descr;
- struct timeval timeout;
int sockl;
LOGHDMILIB("%s begin", __func__);
@@ -201,7 +202,7 @@ void thread_socklisten_fn(void *arg)
if (socknew >= 0)
/* Create a client thread */
pthread_create(&thread_sockclient, NULL,
- (void *)thread_sockclient_fn, (void *)socknew);
+ (void *)thread_sockclient_fn, (void *)&socknew);
}
thread_socklisten_fn_end:
@@ -275,7 +276,6 @@ int serversocket_create(int avoid_return_msg)
int sock;
int len;
struct sockaddr_un addr;
- int result;
int n;
LOGHDMILIB("%s begin", __func__);