Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/apps/debug_menu.c b/apps/debug_menu.c
- index aec0a9a..f62ea89 100644
- --- a/apps/debug_menu.c
- +++ b/apps/debug_menu.c
- @@ -1915,7 +1915,7 @@ static bool dbg_fm_radio(void)
- #endif /* CONFIG_TUNER */
- #endif /* !SIMULATOR */
- -#if defined(HAVE_LCD_BITMAP) && !defined(APPLICATION)
- +#if defined(HAVE_LCD_BITMAP) && (!defined(APPLICATION) || defined(SAMSUNG_YPR0))
- extern bool do_screendump_instead_of_usb;
- static bool dbg_screendump(void)
- @@ -2184,7 +2184,7 @@ static const struct {
- #if (CONFIG_BATTERY_MEASURE != 0) && !defined(SIMULATOR)
- { "View battery", view_battery },
- #endif
- -#ifndef APPLICATION
- +#if (!defined(APPLICATION) || defined(SAMSUNG_YPR0))
- { "Screendump", dbg_screendump },
- #endif
- #endif
- diff --git a/apps/main.c b/apps/main.c
- index 6b6566c..05df4ed 100644
- --- a/apps/main.c
- +++ b/apps/main.c
- @@ -421,6 +421,8 @@ static void init(void)
- scrobbler_init();
- audio_init();
- +
- + usb_init();
- #if (CONFIG_CODEC == SWCODEC) && defined(HAVE_RECORDING)
- pcm_rec_init();
- diff --git a/firmware/SOURCES b/firmware/SOURCES
- index f5e2c76..6231f10 100644
- --- a/firmware/SOURCES
- +++ b/firmware/SOURCES
- @@ -96,6 +96,7 @@ target/hosted/ypr0/audio-ypr0.c
- #if CONFIG_TUNER
- target/hosted/ypr0/radio-ypr0.c
- #endif
- +target/hosted/ypr0/usb-ypr0.c
- #endif
- /* Maemo specific files */
- diff --git a/firmware/export/config/samsungypr0.h b/firmware/export/config/samsungypr0.h
- index e97dabc..29e05a1 100644
- --- a/firmware/export/config/samsungypr0.h
- +++ b/firmware/export/config/samsungypr0.h
- @@ -12,11 +12,10 @@
- #define MODEL_NAME "Samsung YP-R0"
- -/* Indeed to check that */
- -/*TODO: R0 should charge battery automatically, no software stuff to manage that. Just to know about some as3543 registers, that should be set after loading samsung's afe.ko module
- - */
- /*TODO: implement USB data transfer management -> see safe mode script and think a way to implemtent it in the code */
- -#define USB_NONE
- +//#define USB_NONE
- +//#define HAVE_USBSTACK
- +//#define USE_ROCKBOX_USB
- /* There is only USB charging */
- //#define HAVE_USB_POWER
- diff --git a/firmware/screendump.c b/firmware/screendump.c
- index 0dfe79a..0e19d24 100644
- --- a/firmware/screendump.c
- +++ b/firmware/screendump.c
- @@ -28,6 +28,9 @@
- #include "stdlib.h"
- #include "string.h"
- #include "system.h"
- +#ifdef SAMSUNG_YPR0
- + #include "rbpaths.h"
- +#endif
- #ifdef HAVE_REMOTE_LCD
- #include "lcd-remote.h"
- @@ -120,11 +123,20 @@ void screen_dump(void)
- #endif
- #if CONFIG_RTC
- +#ifdef SAMSUNG_YPR0
- + create_datetime_filename(filename, HOME_DIR, "dump ", ".bmp", false);
- +#else
- create_datetime_filename(filename, "", "dump ", ".bmp", false);
- +#endif
- +#else
- +#ifdef SAMSUNG_YPR0
- + create_numbered_filename(filename, HOME_DIR, "dump_", ".bmp", 4
- + IF_CNFN_NUM_(, NULL));
- #else
- create_numbered_filename(filename, "", "dump_", ".bmp", 4
- IF_CNFN_NUM_(, NULL));
- #endif
- +#endif
- fd = creat(filename, 0666);
- if (fd < 0)
- diff --git a/firmware/target/hosted/ypr0/usb-ypr0.c b/firmware/target/hosted/ypr0/usb-ypr0.c
- new file mode 100644
- index 0000000..0ee4756
- --- /dev/null
- +++ b/firmware/target/hosted/ypr0/usb-ypr0.c
- @@ -0,0 +1,68 @@
- +/***************************************************************************
- + * __________ __ ___.
- + * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- + * \/ \/ \/ \/ \/
- + * $Id$
- + *
- + * Copyright (C) 2012 Lorenzo Miori
- + *
- + * This program is free software; you can redistribute it and/or
- + * modify it under the terms of the GNU General Public License
- + * as published by the Free Software Foundation; either version 2
- + * of the License, or (at your option) any later version.
- + *
- + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- + * KIND, either express or implied.
- + *
- + ****************************************************************************/
- +#include "config.h"
- +#include "stdbool.h"
- +#include "system.h"
- +#include "kernel.h"
- +#include "usb.h"
- +#include "sc900776.h"
- +#include "unistd.h"
- +#include "fcntl.h"
- +#include "stdio.h"
- +#include "sys/ioctl.h"
- +#include "stdlib.h"
- +
- +//static bool usb_attached = false;
- +
- +void usb_init_device(void)
- +{
- + /* Start usb detection... */
- + usb_start_monitoring();
- +}
- +
- +int usb_detect(void)
- +{
- + unsigned status = USB_EXTRACTED;
- + /* Check if this register is set...DEVICE_1 */
- + sMinivet_t rs = { .addr = 0xA, .value = 0 };
- + int fd = open("/dev/minivet", O_RDONLY); //TODO: open a single instance that remains open until app shutdown
- + // since that's also used to see if we are connected to a charger
- + if (fd >= 0)
- + {
- + if (ioctl(fd, IOCTL_MINIVET_READ_BYTE, &rs) >= 0) {
- + printf("%i", rs.value);
- + status = (rs.value >> 2) ? USB_INSERTED : USB_EXTRACTED;
- + }
- + close(fd);
- + }
- + return status;
- +}
- +
- +void usb_enable(bool on)
- +{
- + //TODO: of course that won't be so in the end...
- + if (on) {
- + system("./usb_on");
- + }
- + else {
- + system("./usb_off");
- + }
- +}
- diff --git a/firmware/usb.c b/firmware/usb.c
- index 6823851..a482002 100644
- --- a/firmware/usb.c
- +++ b/firmware/usb.c
- @@ -51,7 +51,8 @@
- (defined(HAVE_USBSTACK) && defined(USE_ROCKBOX_USB) && CONFIG_USBOTG == USBOTG_S3C6400X) || \
- defined(CPU_TCC77X) || defined(CPU_TCC780X) || \
- (CONFIG_USBOTG == USBOTG_JZ4740) || \
- - (defined(USE_ROCKBOX_USB) && CONFIG_USBOTG == USBOTG_AS3525)
- + (defined(USE_ROCKBOX_USB) && CONFIG_USBOTG == USBOTG_AS3525) || \
- + (defined(SAMSUNG_YPR0))
- #define USB_FULL_INIT
- #endif
- @@ -322,15 +323,19 @@ static inline bool usb_configure_drivers(int for_state)
- static inline void usb_slave_mode(bool on)
- {
- +#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
- int rc;
- +#endif
- if(on)
- {
- DEBUGF("Entering USB slave mode\n");
- +#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
- disk_unmount_all();
- storage_soft_reset();
- storage_init();
- storage_enable(false);
- +#endif
- usb_enable(true);
- cpu_idle_mode(true);
- }
- @@ -345,6 +350,7 @@ static inline void usb_slave_mode(bool on)
- usb_enable(false);
- +#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
- rc = storage_init();
- if(rc)
- panicf("storage: %d",rc);
- @@ -353,6 +359,7 @@ static inline void usb_slave_mode(bool on)
- rc = disk_mount_all();
- if(rc <= 0) /* no partition */
- panicf("mount: %d",rc);
- +#endif
- }
- }
- #endif /* HAVE_USBSTACK */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement