Skip to content

Commit

Permalink
* udev is now default cable detecting hal
Browse files Browse the repository at this point in the history
* small fixed for appsync less builds
Signed-off-by: Philippe De Swert <phdeswer@lumi.maa>
  • Loading branch information
Philippe De Swert committed Apr 8, 2011
1 parent 44d0373 commit b2686cc
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 14 deletions.
2 changes: 1 addition & 1 deletion debian/rules
Expand Up @@ -23,7 +23,7 @@ configure-stamp:
dh_testdir
# Add here commands to configure the package.
if [ ! -x configure ]; then ./autogen.sh; fi
./configure --prefix=/usr --enable-nokia --enable-app-sync --enable-bme
./configure --prefix=/usr --enable-nokia --enable-app-sync --enable-udev

touch configure-stamp

Expand Down
6 changes: 0 additions & 6 deletions src/usb_moded-appsync.c
Expand Up @@ -203,12 +203,6 @@ gboolean enumerate_usb(gpointer data)
if(data != NULL)
usb_moded_appsync_cleanup((GList *)data);

#ifdef NOKIA
/* timeout for exporting CDROM image */
g_timeout_add_seconds(1, export_cdrom, data);

#endif /* NOKIA */

/* return false to stop the timer from repeating */
return(FALSE);
}
7 changes: 7 additions & 0 deletions src/usb_moded-modesetting.c
Expand Up @@ -157,16 +157,23 @@ int set_ovi_suite_mode(GList *applist)
{
int net = 0;

#ifdef APP_SYNC
/* do not go through the appsync routine if there is no applist */
if(applist)
activate_sync(applist);
else
enumerate_usb(NULL);
#else
system("echo 1 > /sys/devices/platform/musb_hdrc/gadget/softconnect");
#endif /* APP_SYNC */
/* bring network interface up in case no other network is up */
net = system("route -n | grep default");
if(net)
net = system("ifdown usb0 ; ifup usb0");

/* timeout for exporting CDROM image */
g_timeout_add_seconds(1, export_cdrom, NULL);

return(0);
}

Expand Down
29 changes: 25 additions & 4 deletions src/usb_moded-udev.c
Expand Up @@ -26,6 +26,7 @@ gboolean hwal_init(void)
{
GThread * thread;
const gchar *udev_path = NULL;
const char *tmp;

/* Create the udev object */
udev = udev_new();
Expand Down Expand Up @@ -53,6 +54,25 @@ gboolean hwal_init(void)
}
udev_monitor_filter_add_match_subsystem_devtype(mon, "power_supply", NULL);
udev_monitor_enable_receiving (mon);

/* check if we are already connected */
tmp = udev_device_get_property_value(dev, "POWER_SUPPLY_PRESENT");
if(!tmp)
tmp = udev_device_get_property_value(dev, "POWER_SUPPLY_ONLINE");
if(!tmp)
{
log_err("No usable power supply indicator\n");
return 0;
}
if(!strcmp(tmp, "1"))
{
if(!strcmp(udev_device_get_property_value(dev, "POWER_SUPPLY_TYPE"), "USB")||
!strcmp(udev_device_get_property_value(dev, "POWER_SUPPLY_TYPE"), "USB_CDP"))
{
log_debug("UDEV:USB cable connected\n");
set_usb_connected(TRUE);
}
}

thread = g_thread_create(monitor_udev, NULL, FALSE, NULL);

Expand All @@ -76,9 +96,9 @@ gpointer monitor_udev(gpointer data)
{
if(!strcmp(udev_device_get_action(dev), "change"))
{
tmp = udev_device_get_property_value(dev, "POWER_SUPPLY_PRESENT");
tmp = udev_device_get_property_value(dev, "POWER_SUPPLY_ONLINE");
if(!tmp)
tmp = udev_device_get_property_value(dev, "POWER_SUPPLY_ONLINE");
tmp = udev_device_get_property_value(dev, "POWER_SUPPLY_PRESENT");
if(!tmp)
{
log_err("No usable power supply indicator\n");
Expand All @@ -87,8 +107,9 @@ gpointer monitor_udev(gpointer data)
if(!strcmp(tmp, "1"))
{
log_debug("UDEV:power supply present\n");
/* POWER_SUPPLY_TYPE is USB if usb cable is connected, or USB_DCP for charger */
if(!strcmp(udev_device_get_property_value(dev, "POWER_SUPPLY_TYPE"), "USB"))
/* POWER_SUPPLY_TYPE is USB if usb cable is connected, USB_CDP for charging hub or USB_DCP for charger */
if(!strcmp(udev_device_get_property_value(dev, "POWER_SUPPLY_TYPE"), "USB")||
!strcmp(udev_device_get_property_value(dev, "POWER_SUPPLY_TYPE"), "USB_CDP"))
{
log_debug("UDEV:USB cable connected\n");
set_usb_connected(TRUE);
Expand Down
6 changes: 3 additions & 3 deletions src/usb_moded.c
Expand Up @@ -57,9 +57,9 @@ gboolean special_mode = FALSE;
guint timeout_source = 0;
#endif /* NOKIA */

#ifdef APP_SYNC
/*#ifdef APP_SYNC */
GList *applist = NULL;
#endif /* APP_SYNC */
/*#endif APP_SYNC */

/* static helper functions */
static void usb_moded_init(void);
Expand Down Expand Up @@ -116,7 +116,7 @@ void set_usb_connected(gboolean connected)
usb_moded_mode_cleanup(get_usb_module());
usb_moded_send_signal(USB_DISCONNECTED);
#ifdef NOKIA
timeout_source = g_timeout_add_seconds(8, usb_module_timeout_cleanup, NULL);
timeout_source = g_timeout_add_seconds(10, usb_module_timeout_cleanup, NULL);
#else
/* unload modules and general cleanup */
usb_moded_module_cleanup(get_usb_module());
Expand Down

0 comments on commit b2686cc

Please sign in to comment.