blob: bf47366d6b598537e4d6d6b8436890346abf5add [file] [log] [blame]
Baruch Eruchimovitch8c3f7802013-01-05 22:48:04 +02001/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
Baruch Eruchimovitche9cbfc12011-10-09 19:47:08 +02002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 */
13#ifndef __Q6_USM_H__
14#define __Q6_USM_H__
15
16#include <mach/qdsp6v2/apr_us.h>
17
Baruch Eruchimovitch258b3472012-10-14 21:46:35 +020018#define Q6USM_EVENT_UNDEF 0
19#define Q6USM_EVENT_READ_DONE 1
20#define Q6USM_EVENT_WRITE_DONE 2
21#define Q6USM_EVENT_SIGNAL_DETECT_RESULT 3
22
Baruch Eruchimovitch24dda6a2012-01-02 20:28:19 +020023/* cyclic buffer with 1 gap support */
24#define USM_MIN_BUF_CNT 3
25
Baruch Eruchimovitche9cbfc12011-10-09 19:47:08 +020026#define FORMAT_USPS_EPOS 0x00000000
27#define FORMAT_USRAW 0x00000001
Baruch Eruchimovitchfc1036e2012-09-19 17:35:22 +030028#define FORMAT_USPROX 0x00000002
Baruch Eruchimovitche9cbfc12011-10-09 19:47:08 +020029#define INVALID_FORMAT 0xffffffff
30
31#define IN 0x000
32#define OUT 0x001
33
34#define USM_WRONG_TOKEN 0xffffffff
35#define USM_UNDEF_TOKEN 0xfffffffe
36
37#define CMD_CLOSE 0x0004
38
39/* bit 0:1 represents priority of stream */
40#define STREAM_PRIORITY_NORMAL 0x0000
41#define STREAM_PRIORITY_LOW 0x0001
42#define STREAM_PRIORITY_HIGH 0x0002
43
44/* bit 4 represents META enable of encoded data buffer */
45#define BUFFER_META_ENABLE 0x0010
46
Baruch Eruchimovitche9cbfc12011-10-09 19:47:08 +020047struct us_port_data {
48 dma_addr_t phys;
49 /* cyclic region of buffers with 1 gap */
50 void *data;
51 /* number of buffers in the region */
52 uint32_t buf_cnt;
53 /* size of buffer */
54 uint32_t buf_size;
Baruch Eruchimovitch258b3472012-10-14 21:46:35 +020055 /* write index */
Baruch Eruchimovitche9cbfc12011-10-09 19:47:08 +020056 uint32_t dsp_buf;
Baruch Eruchimovitch258b3472012-10-14 21:46:35 +020057 /* read index */
Baruch Eruchimovitche9cbfc12011-10-09 19:47:08 +020058 uint32_t cpu_buf;
59 /* expected token from dsp */
60 uint32_t expected_token;
61 /* read or write locks */
62 struct mutex lock;
63 spinlock_t dsp_lock;
Baruch Eruchimovitch258b3472012-10-14 21:46:35 +020064 /* extended parameters, related to q6 variants */
Baruch Eruchimovitch8c3f7802013-01-05 22:48:04 +020065 void *ext;
Baruch Eruchimovitche9cbfc12011-10-09 19:47:08 +020066};
67
68struct us_client {
69 int session;
70 /* idx:1 out port, 0: in port*/
71 struct us_port_data port[2];
72
73 struct apr_svc *apr;
74 struct mutex cmd_lock;
75
76 atomic_t cmd_state;
77 atomic_t eos_state;
78 wait_queue_head_t cmd_wait;
79
80 void (*cb)(uint32_t, uint32_t, uint32_t *, void *);
81 void *priv;
82};
83
84int q6usm_run(struct us_client *usc, uint32_t flags,
85 uint32_t msw_ts, uint32_t lsw_ts);
86int q6usm_cmd(struct us_client *usc, int cmd);
87int q6usm_us_client_buf_alloc(unsigned int dir, struct us_client *usc,
88 unsigned int bufsz, unsigned int bufcnt);
89int q6usm_enc_cfg_blk(struct us_client *usc, struct us_encdec_cfg *us_cfg);
90int q6usm_dec_cfg_blk(struct us_client *usc, struct us_encdec_cfg *us_cfg);
91int q6usm_read(struct us_client *usc, uint32_t read_ind);
92struct us_client *q6usm_us_client_alloc(
93 void (*cb)(uint32_t, uint32_t, uint32_t *, void *),
94 void *priv);
95int q6usm_open_read(struct us_client *usc, uint32_t format);
96void q6usm_us_client_free(struct us_client *usc);
Baruch Eruchimovitche9cbfc12011-10-09 19:47:08 +020097uint32_t q6usm_get_virtual_address(int dir, struct us_client *usc,
98 struct vm_area_struct *vms);
Baruch Eruchimovitche9cbfc12011-10-09 19:47:08 +020099int q6usm_open_write(struct us_client *usc, uint32_t format);
100int q6usm_write(struct us_client *usc, uint32_t write_ind);
Baruch Eruchimovitch258b3472012-10-14 21:46:35 +0200101bool q6usm_is_write_buf_full(struct us_client *usc, uint32_t *free_region);
Baruch Eruchimovitch24dda6a2012-01-02 20:28:19 +0200102int q6usm_set_us_detection(struct us_client *usc,
103 struct usm_session_cmd_detect_info *detect_info,
104 uint16_t detect_info_size);
105
Baruch Eruchimovitche9cbfc12011-10-09 19:47:08 +0200106#endif /* __Q6_USM_H__ */