From d1cabf6caa363b444ec052862740619ae375ad36 Mon Sep 17 00:00:00 2001 From: taeyoung Date: Fri, 30 Oct 2015 17:57:28 +0900 Subject: [PATCH] sdb: do not init usb protocol is the profile is TV - In the TV target, there is no usb connection for sdb. Thus usb protocol init operation should be removed Change-Id: I4d2d6cd631d39468ab283eb47d8502ad04f7aa45 Signed-off-by: taeyoung --- packaging/sdbd_tcp.service | 2 +- src/sdb.c | 94 ++++++++++++++++++++++++++++++++-------------- src/sdb.h | 9 +++++ src/usb_funcfs_client.c | 2 +- 4 files changed, 77 insertions(+), 30 deletions(-) diff --git a/packaging/sdbd_tcp.service b/packaging/sdbd_tcp.service index 15b4c8a..4ded27c 100644 --- a/packaging/sdbd_tcp.service +++ b/packaging/sdbd_tcp.service @@ -8,4 +8,4 @@ Environment=DISPLAY=:0 PIDFile=/tmp/.sdbd.pid RemainAfterExit=yes SmackProcessLabel=User -ExecStart=/usr/sbin/sdbd --listen=26101 +ExecStart=/usr/sbin/sdbd --listen-port=26101 diff --git a/src/sdb.c b/src/sdb.c index 44a2144..8b9f7cc 100644 --- a/src/sdb.c +++ b/src/sdb.c @@ -1166,9 +1166,44 @@ static void init_sdk_requirements() { } #endif /* !SDB_HOST */ +static void get_plugin_capability(void) +{ + int len; + char *usb_state; + char *sock_state; + + if (is_emulator()) + usb_state = SDBD_CAP_RET_DISABLED; + else + usb_state = SDBD_CAP_RET_ENABLED; + + sock_state = SDBD_CAP_RET_ENABLED; + + len = sizeof(g_capabilities.usbproto_support); + snprintf(g_capabilities.usbproto_support, len, + "%s", usb_state); + + len = sizeof(g_capabilities.sockproto_support); + snprintf(g_capabilities.sockproto_support, len, + "%s", sock_state); +} + +static int is_support_usbproto() +{ + return (!strncmp(g_capabilities.usbproto_support, + SDBD_CAP_RET_ENABLED, strlen(SDBD_CAP_RET_ENABLED))); +} + +static int is_support_sockproto() +{ + return (!strncmp(g_capabilities.sockproto_support, + SDBD_CAP_RET_ENABLED, strlen(SDBD_CAP_RET_ENABLED))); +} + int sdb_main(int is_daemon, int server_port) { #if !SDB_HOST + get_plugin_capability(); init_drop_privileges(); init_sdk_requirements(); umask(000); @@ -1241,34 +1276,37 @@ int sdb_main(int is_daemon, int server_port) } } - if (!is_emulator()) { - /* choose the usb gadget backend */ - if (access(USB_NODE_FILE, F_OK) == 0) { - /* legacy kernel-based sdb gadget */ - usb_init = &linux_usb_init; - usb_cleanup = &linux_usb_cleanup; - usb_write = &linux_usb_write; - usb_read = &linux_usb_read; - usb_close = &linux_usb_close; - usb_kick = &linux_usb_kick; - } else { - /* functionfs based gadget */ - usb_init = &ffs_usb_init; - usb_cleanup = &ffs_usb_cleanup; - usb_write = &ffs_usb_write; - usb_read = &ffs_usb_read; - usb_close = &ffs_usb_close; - usb_kick = &ffs_usb_kick; - } - // listen on USB - usb_init(); - } - - /* by default don't listen on local transport but - * listen if suitable command line argument has been provided */ - if (sdbd_commandline_args.sdbd_port >= 0) { - local_init(sdbd_commandline_args.sdbd_port); - } + if (is_support_usbproto()) { + if (!is_emulator()) { + /* choose the usb gadget backend */ + if (access(USB_NODE_FILE, F_OK) == 0) { + /* legacy kernel-based sdb gadget */ + usb_init = &linux_usb_init; + usb_cleanup = &linux_usb_cleanup; + usb_write = &linux_usb_write; + usb_read = &linux_usb_read; + usb_close = &linux_usb_close; + usb_kick = &linux_usb_kick; + } else { + /* functionfs based gadget */ + usb_init = &ffs_usb_init; + usb_cleanup = &ffs_usb_cleanup; + usb_write = &ffs_usb_write; + usb_read = &ffs_usb_read; + usb_close = &ffs_usb_close; + usb_kick = &ffs_usb_kick; + } + // listen on USB + usb_init(); + } + } + + if (is_support_sockproto()) { + /* by default don't listen on local transport but + * listen if suitable command line argument has been provided */ + if (sdbd_commandline_args.sdbd_port >= 0) + local_init(sdbd_commandline_args.sdbd_port); + } #if 0 /* tizen specific */ D("sdb_main(): pre init_jdwp()\n"); diff --git a/src/sdb.h b/src/sdb.h index 923fdec..da25ab1 100644 --- a/src/sdb.h +++ b/src/sdb.h @@ -228,6 +228,15 @@ struct alistener adisconnect disconnect; }; +#define SDBD_CAP_RET_ENABLED "enabled" +#define SDBD_CAP_RET_DISABLED "disabled" +#define CAPBUF_ITEMSIZE 32 +typedef struct platform_capabilities +{ + char usbproto_support[CAPBUF_ITEMSIZE]; // enabled or disabled + char sockproto_support[CAPBUF_ITEMSIZE]; // enabled or disabled +} pcap; +pcap g_capabilities; void print_packet(const char *label, apacket *p); diff --git a/src/usb_funcfs_client.c b/src/usb_funcfs_client.c index af9fd2b..dd2abf6 100644 --- a/src/usb_funcfs_client.c +++ b/src/usb_funcfs_client.c @@ -475,7 +475,7 @@ void ffs_usb_init() h = calloc(1, sizeof(usb_handle)); if (autoconfig(h) < 0) { - fatal_errno("[ can't recognize usb FunctionFS bulk device ]\n"); + perror("[ can't recognize usb FunctionFS bulk device ]\n"); free(h); return; } -- 2.7.4