summaryrefslogtreecommitdiff
path: root/firmware/target/hosted/ypr0/ascodec-target.h
diff options
context:
space:
mode:
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 */