summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenzo Miori <memorys60@gmail.com>2013-02-23 16:59:49 +0100
committerThomas Martitz <kugel@rockbox.org>2013-03-06 00:21:22 +0100
commit60592165ca998875e4bc46c4396c5a123a7e9dbb (patch)
tree60b53e6b733fd49bef249761789e97a4bedbef03
parent3e4be68f8b596cf3467f993dc9a210a3d901ca1c (diff)
downloadrockbox-60592165ca998875e4bc46c4396c5a123a7e9dbb.zip
rockbox-60592165ca998875e4bc46c4396c5a123a7e9dbb.tar.gz
rockbox-60592165ca998875e4bc46c4396c5a123a7e9dbb.tar.bz2
rockbox-60592165ca998875e4bc46c4396c5a123a7e9dbb.tar.xz
Samsung YP-R0 hosted target code refactoring
As per title this patch aims at splitting common target code and specific target code in a better way to support future ports within the same environment (e.g. Samsung YP-R1 where the Linux and the SoC are the same, with differences in hardware devices handling) Change-Id: I67b4918c46403b184d3d8f42ab5aae7d01037fd0 Reviewed-on: http://gerrit.rockbox.org/409 Reviewed-by: Thomas Martitz <kugel@rockbox.org> Tested-by: Thomas Martitz <kugel@rockbox.org>
-rw-r--r--firmware/SOURCES18
-rw-r--r--firmware/export/config/samsungypr0.h13
-rw-r--r--firmware/target/hosted/samsungypr/adc-target.h (renamed from firmware/target/hosted/ypr0/adc-target.h)0
-rw-r--r--firmware/target/hosted/samsungypr/backlight-target.h (renamed from firmware/target/hosted/ypr0/backlight-target.h)2
-rw-r--r--firmware/target/hosted/samsungypr/dir-target.h (renamed from firmware/target/hosted/ypr0/dir-target.h)0
-rw-r--r--firmware/target/hosted/samsungypr/gpio_ypr.c (renamed from firmware/target/hosted/ypr0/gpio_ypr0.c)2
-rw-r--r--firmware/target/hosted/samsungypr/lcd-target.h (renamed from firmware/target/hosted/ypr0/lcd-target.h)0
-rw-r--r--firmware/target/hosted/samsungypr/lcd-ypr.c (renamed from firmware/target/hosted/ypr0/lcd-ypr0.c)0
-rw-r--r--firmware/target/hosted/samsungypr/radio-ypr.c (renamed from firmware/target/hosted/ypr0/radio-ypr0.c)5
-rw-r--r--firmware/target/hosted/samsungypr/radio-ypr.h (renamed from firmware/target/hosted/ypr0/radio-ypr0.h)0
-rw-r--r--firmware/target/hosted/samsungypr/si4709.h (renamed from firmware/target/hosted/ypr0/si4709.h)0
-rw-r--r--firmware/target/hosted/samsungypr/system-target.h (renamed from firmware/target/hosted/ypr0/system-target.h)0
-rw-r--r--firmware/target/hosted/samsungypr/ypr0/ascodec-ypr0.c (renamed from firmware/target/hosted/ypr0/ascodec-ypr0.c)26
-rw-r--r--firmware/target/hosted/samsungypr/ypr0/audio-ypr0.c (renamed from firmware/target/hosted/ypr0/audio-ypr0.c)0
-rw-r--r--firmware/target/hosted/samsungypr/ypr0/backlight-ypr0.c (renamed from firmware/target/hosted/ypr0/backlight-ypr0.c)0
-rw-r--r--firmware/target/hosted/samsungypr/ypr0/button-target.h (renamed from firmware/target/hosted/ypr0/button-target.h)0
-rw-r--r--firmware/target/hosted/samsungypr/ypr0/button-ypr0.c (renamed from firmware/target/hosted/ypr0/button-ypr0.c)2
-rw-r--r--firmware/target/hosted/samsungypr/ypr0/gpio-target.h (renamed from firmware/target/hosted/ypr0/gpio_ypr0.h)0
-rw-r--r--firmware/target/hosted/samsungypr/ypr0/powermgmt-ypr0.c (renamed from firmware/target/hosted/ypr0/powermgmt-ypr0.c)3
-rw-r--r--firmware/target/hosted/samsungypr/ypr0/r0GPIOIoctl.h (renamed from firmware/target/hosted/ypr0/r0GPIOIoctl.h)0
-rw-r--r--firmware/target/hosted/samsungypr/ypr0/sc900776.h (renamed from firmware/target/hosted/ypr0/sc900776.h)0
-rw-r--r--firmware/target/hosted/samsungypr/ypr0/system-ypr0.c (renamed from firmware/target/hosted/ypr0/system-ypr0.c)6
-rw-r--r--firmware/target/hosted/samsungypr/ypr0/ypr0.make (renamed from firmware/target/hosted/ypr0/ypr0.make)0
-rwxr-xr-xtools/configure4
-rw-r--r--tools/root.make2
25 files changed, 45 insertions, 38 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 887445b..8ba45af 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -82,19 +82,19 @@ target/hosted/rtc.c
target/hosted/kernel-unix.c
target/hosted/filesystem-unix.c
target/hosted/lc-unix.c
-target/hosted/ypr0/button-ypr0.c
-target/hosted/ypr0/lcd-ypr0.c
-target/hosted/ypr0/system-ypr0.c
+target/hosted/samsungypr/ypr0/button-ypr0.c
+target/hosted/samsungypr/lcd-ypr.c
+target/hosted/samsungypr/ypr0/system-ypr0.c
thread.c
#ifdef HAVE_BACKLIGHT
-target/hosted/ypr0/backlight-ypr0.c
+target/hosted/samsungypr/ypr0/backlight-ypr0.c
#endif
-target/hosted/ypr0/ascodec-ypr0.c
-target/hosted/ypr0/powermgmt-ypr0.c
-target/hosted/ypr0/gpio_ypr0.c
-target/hosted/ypr0/audio-ypr0.c
+target/hosted/samsungypr/ypr0/ascodec-ypr0.c
+target/hosted/samsungypr/ypr0/powermgmt-ypr0.c
+target/hosted/samsungypr/gpio_ypr.c
+target/hosted/samsungypr/ypr0/audio-ypr0.c
#if CONFIG_TUNER
-target/hosted/ypr0/radio-ypr0.c
+target/hosted/samsungypr/radio-ypr.c
#endif
#endif
diff --git a/firmware/export/config/samsungypr0.h b/firmware/export/config/samsungypr0.h
index debe9a3..c81fc64 100644
--- a/firmware/export/config/samsungypr0.h
+++ b/firmware/export/config/samsungypr0.h
@@ -12,9 +12,6 @@
#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
@@ -94,20 +91,26 @@
#define HAVE_AS3514
#define HAVE_AS3543
+/* We don't have hardware controls */
#define HAVE_SW_TONE_CONTROLS
+/* We have the Si4709, which supports RDS */
#define CONFIG_TUNER SI4700
#define HAVE_TUNER_PWR_CTRL
-
#define HAVE_RDS_CAP
/* Define this for FM radio input available */
#define HAVE_FMRADIO_IN
#define INPUT_SRC_CAPS SRC_CAP_FMRADIO
-/* We have a GPIO that detects it */
+/* We have a GPIO pin that detects this */
#define HAVE_HEADPHONE_DETECTION
+/* FIXME
+ * Lot of people reports bad battery life and funny charging times.
+ * Check what's going on...
+ */
+
#define BATTERY_CAPACITY_DEFAULT 600 /* default battery capacity */
#define BATTERY_CAPACITY_MIN 600 /* min. capacity selectable */
#define BATTERY_CAPACITY_MAX 600 /* max. capacity selectable */
diff --git a/firmware/target/hosted/ypr0/adc-target.h b/firmware/target/hosted/samsungypr/adc-target.h
index e69de29..e69de29 100644
--- a/firmware/target/hosted/ypr0/adc-target.h
+++ b/firmware/target/hosted/samsungypr/adc-target.h
diff --git a/firmware/target/hosted/ypr0/backlight-target.h b/firmware/target/hosted/samsungypr/backlight-target.h
index 561e159..21db75c 100644
--- a/firmware/target/hosted/ypr0/backlight-target.h
+++ b/firmware/target/hosted/samsungypr/backlight-target.h
@@ -5,7 +5,7 @@
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
- * $Id: backlight-target.h 19322 2008-12-04 04:16:53Z jethead71 $
+ * $Id$
*
* Copyright (C) 2011 by Lorenzo Miori
*
diff --git a/firmware/target/hosted/ypr0/dir-target.h b/firmware/target/hosted/samsungypr/dir-target.h
index 7df9554..7df9554 100644
--- a/firmware/target/hosted/ypr0/dir-target.h
+++ b/firmware/target/hosted/samsungypr/dir-target.h
diff --git a/firmware/target/hosted/ypr0/gpio_ypr0.c b/firmware/target/hosted/samsungypr/gpio_ypr.c
index 3ee371d..0d4a7ec 100644
--- a/firmware/target/hosted/ypr0/gpio_ypr0.c
+++ b/firmware/target/hosted/samsungypr/gpio_ypr.c
@@ -23,7 +23,7 @@
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
-#include <gpio_ypr0.h> /* includes r0GPIOioctl.h */
+#include <gpio-target.h> /* includes common ioctl device definitions */
#include <sys/ioctl.h>
static int r0_gpio_dev = 0;
diff --git a/firmware/target/hosted/ypr0/lcd-target.h b/firmware/target/hosted/samsungypr/lcd-target.h
index c8a6de7..c8a6de7 100644
--- a/firmware/target/hosted/ypr0/lcd-target.h
+++ b/firmware/target/hosted/samsungypr/lcd-target.h
diff --git a/firmware/target/hosted/ypr0/lcd-ypr0.c b/firmware/target/hosted/samsungypr/lcd-ypr.c
index 40528c2..40528c2 100644
--- a/firmware/target/hosted/ypr0/lcd-ypr0.c
+++ b/firmware/target/hosted/samsungypr/lcd-ypr.c
diff --git a/firmware/target/hosted/ypr0/radio-ypr0.c b/firmware/target/hosted/samsungypr/radio-ypr.c
index 14d5682..1929bb7 100644
--- a/firmware/target/hosted/ypr0/radio-ypr0.c
+++ b/firmware/target/hosted/samsungypr/radio-ypr.c
@@ -6,7 +6,8 @@
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
*
- * Module wrapper for SI4709 FM Radio Chip, using /dev/si470x (si4709.ko) of Samsung YP-R0
+ * Module wrapper for SI4709 FM Radio Chip, using /dev/si470x (si4709.ko)
+ * Samsung YP-R0 & Samsung YP-R1
*
* Copyright (c) 2012 Lorenzo Miori
*
@@ -27,7 +28,7 @@
#include "string.h"
#include "kernel.h"
-#include "radio-ypr0.h"
+#include "radio-ypr.h"
#include "rds.h"
#include "si4700.h"
#include "power.h"
diff --git a/firmware/target/hosted/ypr0/radio-ypr0.h b/firmware/target/hosted/samsungypr/radio-ypr.h
index 13bcb6d..13bcb6d 100644
--- a/firmware/target/hosted/ypr0/radio-ypr0.h
+++ b/firmware/target/hosted/samsungypr/radio-ypr.h
diff --git a/firmware/target/hosted/ypr0/si4709.h b/firmware/target/hosted/samsungypr/si4709.h
index c27472e..c27472e 100644
--- a/firmware/target/hosted/ypr0/si4709.h
+++ b/firmware/target/hosted/samsungypr/si4709.h
diff --git a/firmware/target/hosted/ypr0/system-target.h b/firmware/target/hosted/samsungypr/system-target.h
index 1ef8b9a..1ef8b9a 100644
--- a/firmware/target/hosted/ypr0/system-target.h
+++ b/firmware/target/hosted/samsungypr/system-target.h
diff --git a/firmware/target/hosted/ypr0/ascodec-ypr0.c b/firmware/target/hosted/samsungypr/ypr0/ascodec-ypr0.c
index cc92384..24362af 100644
--- a/firmware/target/hosted/ypr0/ascodec-ypr0.c
+++ b/firmware/target/hosted/samsungypr/ypr0/ascodec-ypr0.c
@@ -5,10 +5,10 @@
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
- *
+ *
* Module wrapper for AS3543 audio codec, using /dev/afe (afe.ko) of Samsung YP-R0
*
- * Copyright (c) 2011 Lorenzo Miori
+ * Copyright (c) 2011-2013 Lorenzo Miori
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -29,11 +29,10 @@
#include "ascodec.h"
-int afe_dev = -1;
+static int afe_dev = -1;
-/* ioctl parameter struct */
+/* Structure used for ioctl module call */
struct codec_req_struct {
-/* This works for every kind of afe.ko module requests */
unsigned char reg; /* Main register address */
unsigned char subreg; /* Set this only if you are reading/writing a PMU register*/
unsigned char value; /* To be read if reading a register; to be set if writing to a register */
@@ -49,28 +48,31 @@ struct codec_req_struct {
/* Read from a PMU register */
#define IOCTL_SUBREG_READ 0x80034103
-
+/* Open device */
void ascodec_init(void)
{
afe_dev = open("/dev/afe", O_RDWR);
}
+/* Close device */
void ascodec_close(void)
{
- if (afe_dev >= 0) {
+ if (afe_dev >= 0)
close(afe_dev);
- }
}
-/* Read functions returns -1 if fail, otherwise the register's value if success */
-/* Write functions return >= 0 if success, otherwise -1 if fail */
-
+/* Write register.
+ * Returns >= 0 if success, -1 if fail
+ */
int ascodec_write(unsigned int reg, unsigned int value)
{
struct codec_req_struct r = { .reg = reg, .value = value };
return ioctl(afe_dev, IOCTL_REG_WRITE, &r);
}
+/* Read register.
+ * Returns -1 if fail, otherwise the register's value if success
+ */
int ascodec_read(unsigned int reg)
{
struct codec_req_struct r = { .reg = reg };
@@ -81,6 +83,7 @@ int ascodec_read(unsigned int reg)
return retval;
}
+/* Write PMU register */
void ascodec_write_pmu(unsigned int index, unsigned int subreg,
unsigned int value)
{
@@ -88,6 +91,7 @@ void ascodec_write_pmu(unsigned int index, unsigned int subreg,
ioctl(afe_dev, IOCTL_SUBREG_WRITE, &r);
}
+/* Read PMU register */
int ascodec_read_pmu(unsigned int index, unsigned int subreg)
{
struct codec_req_struct r = { .reg = index, .subreg = subreg, };
diff --git a/firmware/target/hosted/ypr0/audio-ypr0.c b/firmware/target/hosted/samsungypr/ypr0/audio-ypr0.c
index dfd63ef..dfd63ef 100644
--- a/firmware/target/hosted/ypr0/audio-ypr0.c
+++ b/firmware/target/hosted/samsungypr/ypr0/audio-ypr0.c
diff --git a/firmware/target/hosted/ypr0/backlight-ypr0.c b/firmware/target/hosted/samsungypr/ypr0/backlight-ypr0.c
index 551b386..551b386 100644
--- a/firmware/target/hosted/ypr0/backlight-ypr0.c
+++ b/firmware/target/hosted/samsungypr/ypr0/backlight-ypr0.c
diff --git a/firmware/target/hosted/ypr0/button-target.h b/firmware/target/hosted/samsungypr/ypr0/button-target.h
index 3a38669..3a38669 100644
--- a/firmware/target/hosted/ypr0/button-target.h
+++ b/firmware/target/hosted/samsungypr/ypr0/button-target.h
diff --git a/firmware/target/hosted/ypr0/button-ypr0.c b/firmware/target/hosted/samsungypr/ypr0/button-ypr0.c
index e66ca22..e3ad309 100644
--- a/firmware/target/hosted/ypr0/button-ypr0.c
+++ b/firmware/target/hosted/samsungypr/ypr0/button-ypr0.c
@@ -24,7 +24,7 @@
#include "kernel.h"
#include "system.h"
#include "button-target.h"
-#include <gpio_ypr0.h> /* For headphones sense and buttons */
+#include <gpio-target.h> /* For headphones sense and buttons */
int button_read_device(void)
{
diff --git a/firmware/target/hosted/ypr0/gpio_ypr0.h b/firmware/target/hosted/samsungypr/ypr0/gpio-target.h
index 3c2033b..3c2033b 100644
--- a/firmware/target/hosted/ypr0/gpio_ypr0.h
+++ b/firmware/target/hosted/samsungypr/ypr0/gpio-target.h
diff --git a/firmware/target/hosted/ypr0/powermgmt-ypr0.c b/firmware/target/hosted/samsungypr/ypr0/powermgmt-ypr0.c
index 347e5fa..6e04d25 100644
--- a/firmware/target/hosted/ypr0/powermgmt-ypr0.c
+++ b/firmware/target/hosted/samsungypr/ypr0/powermgmt-ypr0.c
@@ -5,7 +5,6 @@
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
- * $Id: powermgmt-sim.c 29543 2011-03-08 19:33:30Z thomasjfox $
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -24,7 +23,7 @@
#include "file.h"
#include "adc.h"
#include "sc900776.h"
-#include "radio-ypr0.h"
+#include "radio-ypr.h"
const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
{
diff --git a/firmware/target/hosted/ypr0/r0GPIOIoctl.h b/firmware/target/hosted/samsungypr/ypr0/r0GPIOIoctl.h
index e77f35f..e77f35f 100644
--- a/firmware/target/hosted/ypr0/r0GPIOIoctl.h
+++ b/firmware/target/hosted/samsungypr/ypr0/r0GPIOIoctl.h
diff --git a/firmware/target/hosted/ypr0/sc900776.h b/firmware/target/hosted/samsungypr/ypr0/sc900776.h
index 32eb90f..32eb90f 100644
--- a/firmware/target/hosted/ypr0/sc900776.h
+++ b/firmware/target/hosted/samsungypr/ypr0/sc900776.h
diff --git a/firmware/target/hosted/ypr0/system-ypr0.c b/firmware/target/hosted/samsungypr/ypr0/system-ypr0.c
index 11275c7..7ee2697 100644
--- a/firmware/target/hosted/ypr0/system-ypr0.c
+++ b/firmware/target/hosted/samsungypr/ypr0/system-ypr0.c
@@ -5,9 +5,8 @@
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
- * $Id: system-sdl.c 29925 2011-05-25 20:11:03Z thomasjfox $
*
- * Copyright (C) 2006 by Daniel Everton <dan@iocaine.org>
+ * Copyright (C) 2011-2013 by Lorenzo Miori
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -31,7 +30,7 @@
#endif
#include "ascodec.h"
-#include "gpio_ypr0.h"
+#include "gpio-target.h"
void power_off(void)
{
@@ -52,6 +51,7 @@ void system_init(void)
#if defined(HAVE_SDL_AUDIO) || defined(HAVE_SDL_THREADS) || defined(HAVE_SDL)
SDL_Init(0); /* need this if using any SDL subsystem */
#endif
+
/* Here begins our platform specific initilization for various things */
ascodec_init();
gpio_init();
diff --git a/firmware/target/hosted/ypr0/ypr0.make b/firmware/target/hosted/samsungypr/ypr0/ypr0.make
index 67ff326..67ff326 100644
--- a/firmware/target/hosted/ypr0/ypr0.make
+++ b/firmware/target/hosted/samsungypr/ypr0/ypr0.make
diff --git a/tools/configure b/tools/configure
index 442b238..353b991 100755
--- a/tools/configure
+++ b/tools/configure
@@ -3347,8 +3347,8 @@ fi
swcodec="yes"
# architecture, manufacturer and model for the target-tree build
t_cpu="hosted"
- t_manufacturer="ypr0"
- t_model="app"
+ t_manufacturer="samsungypr"
+ t_model="ypr0"
;;
206|androidmips)
diff --git a/tools/root.make b/tools/root.make
index c8c4eb4..b62cb4d 100644
--- a/tools/root.make
+++ b/tools/root.make
@@ -120,7 +120,7 @@ else
endif
ifneq (,$(findstring ypr0,$(APP_TYPE)))
- include $(ROOTDIR)/firmware/target/hosted/ypr0/ypr0.make
+ include $(ROOTDIR)/firmware/target/hosted/samsungypr/ypr0/ypr0.make
endif
ifneq (,$(findstring android, $(APP_TYPE)))