summaryrefslogtreecommitdiff
path: root/firmware/target/hosted
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/hosted')
-rw-r--r--firmware/target/hosted/ypr0/ascodec-target.h80
-rw-r--r--firmware/target/hosted/ypr0/ascodec-ypr0.c37
-rw-r--r--firmware/target/hosted/ypr0/backlight-ypr0.c3
-rw-r--r--firmware/target/hosted/ypr0/gpio_ypr0.c3
-rw-r--r--firmware/target/hosted/ypr0/gpio_ypr0.h3
-rw-r--r--firmware/target/hosted/ypr0/powermgmt-ypr0.c1
-rw-r--r--firmware/target/hosted/ypr0/system-ypr0.c2
7 files changed, 26 insertions, 103 deletions
diff --git a/firmware/target/hosted/ypr0/ascodec-target.h b/firmware/target/hosted/ypr0/ascodec-target.h
deleted file mode 100644
index 2274d5f073..0000000000
--- a/firmware/target/hosted/ypr0/ascodec-target.h
+++ /dev/null
@@ -1,80 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: ascodec-target.h 26116 2010-05-17 20:53:25Z funman $
9 *
10 * Module wrapper for AS3543 audio codec, using /dev/afe (afe.ko) of Samsung YP-R0
11 *
12 * Copyright (c) 2011 Lorenzo Miori
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
18 *
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
21 *
22 ****************************************************************************/
23
24#ifndef _ASCODEC_TARGET_H
25#define _ASCODEC_TARGET_H
26
27#include "as3514.h"
28#include "kernel.h"
29#include "adc.h"
30#include "ascodec.h"
31
32int ascodec_init(void);
33void ascodec_close(void);
34int ascodec_write(unsigned int reg, unsigned int value);
35int ascodec_read(unsigned int reg);
36void ascodec_write_pmu(unsigned int index, unsigned int subreg, unsigned int value);
37int ascodec_read_pmu(unsigned int index, unsigned int subreg);
38int ascodec_readbytes(unsigned int index, unsigned int len, unsigned char *data);
39unsigned short adc_read(int channel);
40void ascodec_lock(void);
41void ascodec_unlock(void);
42
43static inline bool ascodec_chg_status(void)
44{
45 return ascodec_read(AS3514_IRQ_ENRD0) & CHG_STATUS;
46}
47
48static inline bool ascodec_endofch(void)
49{
50 return ascodec_read(AS3514_IRQ_ENRD0) & CHG_ENDOFCH;
51}
52
53static inline void ascodec_monitor_endofch(void)
54{
55 ascodec_write(AS3514_IRQ_ENRD0, IRQ_ENDOFCH);
56}
57
58static inline void ascodec_wait_adc_finished(void)
59{
60 /*
61 * FIXME: not implemented
62 *
63 * If irqs are not available on the target platform,
64 * this should be most likely implemented by polling
65 * AS3514_IRQ_ENRD2 in the same way powermgmt-ascodec.c
66 * is polling IRQ_ENDOFCH.
67 */
68}
69
70static inline void ascodec_write_charger(int value)
71{
72 ascodec_write_pmu(AS3543_CHARGER, 1, value);
73}
74
75static inline int ascodec_read_charger(void)
76{
77 return ascodec_read_pmu(AS3543_CHARGER, 1);
78}
79
80#endif /* !_ASCODEC_TARGET_H */
diff --git a/firmware/target/hosted/ypr0/ascodec-ypr0.c b/firmware/target/hosted/ypr0/ascodec-ypr0.c
index ec5568554b..954b4d95ef 100644
--- a/firmware/target/hosted/ypr0/ascodec-ypr0.c
+++ b/firmware/target/hosted/ypr0/ascodec-ypr0.c
@@ -5,7 +5,6 @@
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id: ascodec-target.h 26116 2010-05-17 20:53:25Z funman $
9 * 8 *
10 * Module wrapper for AS3543 audio codec, using /dev/afe (afe.ko) of Samsung YP-R0 9 * Module wrapper for AS3543 audio codec, using /dev/afe (afe.ko) of Samsung YP-R0
11 * 10 *
@@ -28,7 +27,7 @@
28#include "sys/ioctl.h" 27#include "sys/ioctl.h"
29#include "stdlib.h" 28#include "stdlib.h"
30 29
31#include "ascodec-target.h" 30#include "ascodec.h"
32 31
33int afe_dev = -1; 32int afe_dev = -1;
34 33
@@ -134,24 +133,32 @@ void ascodec_unlock(void)
134{ 133{
135} 134}
136 135
137/* Read 10-bit channel data */ 136bool ascodec_chg_status(void)
138unsigned short adc_read(int channel)
139{ 137{
140 if ((unsigned)channel >= NUM_ADC_CHANNELS) 138 return ascodec_read(AS3514_IRQ_ENRD0) & CHG_STATUS;
141 return 0; 139}
142 140
143 /* Select channel */ 141bool ascodec_endofch(void)
144 ascodec_write(AS3514_ADC_0, (channel << 4)); 142{
145 unsigned char buf[2]; 143 return ascodec_read(AS3514_IRQ_ENRD0) & CHG_ENDOFCH;
144}
145
146void ascodec_monitor_endofch(void)
147{
148 ascodec_write(AS3514_IRQ_ENRD0, IRQ_ENDOFCH);
149}
146 150
147 /* Read data */
148 if (ascodec_readbytes(AS3514_ADC_0, 2, buf) < 0)
149 return 0;
150 151
151 /* decode to 10-bit and return */ 152void ascodec_write_charger(int value)
152 return (((buf[0] & 0x3) << 8) | buf[1]); 153{
154 ascodec_write_pmu(AS3543_CHARGER, 1, value);
155}
156
157int ascodec_read_charger(void)
158{
159 return ascodec_read_pmu(AS3543_CHARGER, 1);
153} 160}
154 161
155void adc_init(void) 162void ascodec_wait_adc_finished(void)
156{ 163{
157} 164}
diff --git a/firmware/target/hosted/ypr0/backlight-ypr0.c b/firmware/target/hosted/ypr0/backlight-ypr0.c
index 930b56be2e..551b386f19 100644
--- a/firmware/target/hosted/ypr0/backlight-ypr0.c
+++ b/firmware/target/hosted/ypr0/backlight-ypr0.c
@@ -5,7 +5,6 @@
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id: backlight-gigabeat-s.c 25800 2010-05-04 10:07:53Z jethead71 $
9 * 8 *
10 * Copyright (C) 2011 by Lorenzo Miori 9 * Copyright (C) 2011 by Lorenzo Miori
11 * 10 *
@@ -24,7 +23,7 @@
24#include "backlight-target.h" 23#include "backlight-target.h"
25#include "lcd.h" 24#include "lcd.h"
26#include "as3514.h" 25#include "as3514.h"
27#include "ascodec-target.h" 26#include "ascodec.h"
28#include <fcntl.h> 27#include <fcntl.h>
29#include "unistd.h" 28#include "unistd.h"
30 29
diff --git a/firmware/target/hosted/ypr0/gpio_ypr0.c b/firmware/target/hosted/ypr0/gpio_ypr0.c
index 9c3f186a6b..3ee371d562 100644
--- a/firmware/target/hosted/ypr0/gpio_ypr0.c
+++ b/firmware/target/hosted/ypr0/gpio_ypr0.c
@@ -5,7 +5,6 @@
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id: ascodec-target.h 26116 2010-05-17 20:53:25Z funman $
9 * 8 *
10 * Module wrapper for GPIO, using /dev/r0GPIO (r0Gpio.ko) of Samsung YP-R0 9 * Module wrapper for GPIO, using /dev/r0GPIO (r0Gpio.ko) of Samsung YP-R0
11 * 10 *
@@ -51,4 +50,4 @@ int gpio_control(int request, int num, int mode, int val)
51{ 50{
52 R0GPIOInfo r = { .num = num, .mode = mode, .val = val, }; 51 R0GPIOInfo r = { .num = num, .mode = mode, .val = val, };
53 return ioctl(r0_gpio_dev, request, &r); 52 return ioctl(r0_gpio_dev, request, &r);
54} \ No newline at end of file 53}
diff --git a/firmware/target/hosted/ypr0/gpio_ypr0.h b/firmware/target/hosted/ypr0/gpio_ypr0.h
index 9fc7444887..ddf7100b2f 100644
--- a/firmware/target/hosted/ypr0/gpio_ypr0.h
+++ b/firmware/target/hosted/ypr0/gpio_ypr0.h
@@ -5,7 +5,6 @@
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id: ascodec-target.h 26116 2010-05-17 20:53:25Z funman $
9 * 8 *
10 * Module wrapper for GPIO, using /dev/r0GPIO (r0Gpio.ko) of Samsung YP-R0 9 * Module wrapper for GPIO, using /dev/r0GPIO (r0Gpio.ko) of Samsung YP-R0
11 * 10 *
@@ -39,4 +38,4 @@ void gpio_close(void);
39int gpio_control_struct(int request, R0GPIOInfo pin); 38int gpio_control_struct(int request, R0GPIOInfo pin);
40int gpio_control(int request, int num, int mode, int val); 39int gpio_control(int request, int num, int mode, int val);
41 40
42#endif \ No newline at end of file 41#endif
diff --git a/firmware/target/hosted/ypr0/powermgmt-ypr0.c b/firmware/target/hosted/ypr0/powermgmt-ypr0.c
index 9c90f7ea02..6aba9c7ef5 100644
--- a/firmware/target/hosted/ypr0/powermgmt-ypr0.c
+++ b/firmware/target/hosted/ypr0/powermgmt-ypr0.c
@@ -22,7 +22,6 @@
22#include "powermgmt.h" 22#include "powermgmt.h"
23#include "power.h" 23#include "power.h"
24#include "file.h" 24#include "file.h"
25#include "ascodec-target.h"
26#include "as3514.h" 25#include "as3514.h"
27#include "sc900776.h" 26#include "sc900776.h"
28 27
diff --git a/firmware/target/hosted/ypr0/system-ypr0.c b/firmware/target/hosted/ypr0/system-ypr0.c
index 784b4fe48e..11275c7809 100644
--- a/firmware/target/hosted/ypr0/system-ypr0.c
+++ b/firmware/target/hosted/ypr0/system-ypr0.c
@@ -30,7 +30,7 @@
30#include <SDL.h> 30#include <SDL.h>
31#endif 31#endif
32 32
33#include "ascodec-target.h" 33#include "ascodec.h"
34#include "gpio_ypr0.h" 34#include "gpio_ypr0.h"
35 35
36void power_off(void) 36void power_off(void)