diff options
author | Lorenzo Miori <memorys60@gmail.com> | 2013-02-23 16:59:49 +0100 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2013-03-06 00:21:22 +0100 |
commit | 60592165ca998875e4bc46c4396c5a123a7e9dbb (patch) | |
tree | 60b53e6b733fd49bef249761789e97a4bedbef03 /firmware/target/hosted | |
parent | 3e4be68f8b596cf3467f993dc9a210a3d901ca1c (diff) | |
download | rockbox-60592165ca998875e4bc46c4396c5a123a7e9dbb.tar.gz rockbox-60592165ca998875e4bc46c4396c5a123a7e9dbb.zip |
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>
Diffstat (limited to 'firmware/target/hosted')
-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 |
21 files changed, 25 insertions, 21 deletions
diff --git a/firmware/target/hosted/ypr0/adc-target.h b/firmware/target/hosted/samsungypr/adc-target.h index e69de29bb2..e69de29bb2 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 561e159e8c..21db75c8c9 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 7df9554e92..7df9554e92 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 3ee371d562..0d4a7eceae 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 c8a6de74f9..c8a6de74f9 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 40528c298a..40528c298a 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 14d56826c1..1929bb7c90 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 13bcb6dc72..13bcb6dc72 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 c27472e856..c27472e856 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 1ef8b9aeda..1ef8b9aeda 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 cc923842df..24362af0c0 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 dfd63ef5cd..dfd63ef5cd 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 551b386f19..551b386f19 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 3a3866932a..3a3866932a 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 e66ca22737..e3ad309187 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 3c2033baff..3c2033baff 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 347e5fa146..6e04d25f58 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 e77f35fbb7..e77f35fbb7 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 32eb90f797..32eb90f797 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 11275c7809..7ee2697a24 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 67ff326de0..67ff326de0 100644 --- a/firmware/target/hosted/ypr0/ypr0.make +++ b/firmware/target/hosted/samsungypr/ypr0/ypr0.make |