summaryrefslogtreecommitdiff
path: root/firmware/target/hosted/ypr0/ascodec-target.h
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2011-12-24 11:56:46 +0000
committerThomas Martitz <kugel@rockbox.org>2011-12-24 11:56:46 +0000
commit249bba03f1051f4984538f66b9e7d36674c61e5c (patch)
treeb9a0d78e05269ed2043521ab0dfdad83aeaf2aff /firmware/target/hosted/ypr0/ascodec-target.h
parent567e0ad93ef3048f2266932b10dcdb309b1a77c9 (diff)
downloadrockbox-249bba03f1051f4984538f66b9e7d36674c61e5c.tar.gz
rockbox-249bba03f1051f4984538f66b9e7d36674c61e5c.zip
Initial commit of the Samsung YP-R0 port.
This port is a hybrid native/RaaA port. It runs on a embedded linux system, but is the only application. It therefore can implement lots of stuff that native targets also implement, while leveraging the underlying linux kernel. The port is quite advanced. User interface, audio playback, plugins work mostly fine. Missing is e.g. power mangement and USB (see SamsungYPR0 wiki page). Included in utils/ypr0tools are scripts and programs required to generate a patched firmware. The patched firmware has the rootfs modified to load Rockbox. It includes a early/safe USB mode. This port needs a new toolchain, one that includes glibc headers and libraries. rockboxdev.sh can generate it, but e.g. codesourcey and distro packages may also work. Most of the initial effort is done by Lorenzo Miori and others (on ABI), including reverse engineering and patching of the original firmware, initial drivers, and more. Big thanks to you. Flyspray: FS#12348 Author: Lorenzo Miori, myself Merry christmas to ypr0 owners! :) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31415 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/hosted/ypr0/ascodec-target.h')
-rw-r--r--firmware/target/hosted/ypr0/ascodec-target.h92
1 files changed, 92 insertions, 0 deletions
diff --git a/firmware/target/hosted/ypr0/ascodec-target.h b/firmware/target/hosted/ypr0/ascodec-target.h
new file mode 100644
index 0000000000..f4ecf20a1b
--- /dev/null
+++ b/firmware/target/hosted/ypr0/ascodec-target.h
@@ -0,0 +1,92 @@
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
32/* ioctl parameter struct */
33
34struct codec_req_struct {
35/* This works for every kind of afe.ko module requests */
36 unsigned char reg; /* Main register address */
37 unsigned char subreg; /* Set this only if you are reading/writing a PMU register*/
38 unsigned char value; /* To be read if reading a register; to be set if writing to a register */
39};
40
41int ascodec_init(void);
42void ascodec_close(void);
43int ascodec_write(unsigned int reg, unsigned int value);
44int ascodec_read(unsigned int reg);
45void ascodec_write_pmu(unsigned int index, unsigned int subreg, unsigned int value);
46int ascodec_read_pmu(unsigned int index, unsigned int subreg);
47void ascodec_set(unsigned int reg, unsigned int bits);
48void ascodec_clear(unsigned int reg, unsigned int bits);
49void ascodec_write_masked(unsigned int reg, unsigned int bits, unsigned int mask);
50int ascodec_readbytes(unsigned int index, unsigned int len, unsigned char *data);
51unsigned short adc_read(int channel);
52void ascodec_lock(void);
53void ascodec_unlock(void);
54
55static inline bool ascodec_chg_status(void)
56{
57 return ascodec_read(AS3514_IRQ_ENRD0) & CHG_STATUS;
58}
59
60static inline bool ascodec_endofch(void)
61{
62 return ascodec_read(AS3514_IRQ_ENRD0) & CHG_ENDOFCH;
63}
64
65static inline void ascodec_monitor_endofch(void)
66{
67 ascodec_write(AS3514_IRQ_ENRD0, IRQ_ENDOFCH);
68}
69
70static inline void ascodec_wait_adc_finished(void)
71{
72 /*
73 * FIXME: not implemented
74 *
75 * If irqs are not available on the target platform,
76 * this should be most likely implemented by polling
77 * AS3514_IRQ_ENRD2 in the same way powermgmt-ascodec.c
78 * is polling IRQ_ENDOFCH.
79 */
80}
81
82static inline void ascodec_write_charger(int value)
83{
84 ascodec_write_pmu(AS3543_CHARGER, 1, value);
85}
86
87static inline int ascodec_read_charger(void)
88{
89 return ascodec_read_pmu(AS3543_CHARGER, 1);
90}
91
92#endif /* !_ASCODEC_TARGET_H */