Baruch Eruchimovitch | 8c3f780 | 2013-01-05 22:48:04 +0200 | [diff] [blame] | 1 | /* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. |
Baruch Eruchimovitch | e9cbfc1 | 2011-10-09 19:47:08 +0200 | [diff] [blame] | 2 | * |
| 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 Eruchimovitch | 258b347 | 2012-10-14 21:46:35 +0200 | [diff] [blame] | 18 | #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 Eruchimovitch | 24dda6a | 2012-01-02 20:28:19 +0200 | [diff] [blame] | 23 | /* cyclic buffer with 1 gap support */ |
| 24 | #define USM_MIN_BUF_CNT 3 |
| 25 | |
Baruch Eruchimovitch | e9cbfc1 | 2011-10-09 19:47:08 +0200 | [diff] [blame] | 26 | #define FORMAT_USPS_EPOS 0x00000000 |
| 27 | #define FORMAT_USRAW 0x00000001 |
Baruch Eruchimovitch | fc1036e | 2012-09-19 17:35:22 +0300 | [diff] [blame] | 28 | #define FORMAT_USPROX 0x00000002 |
Baruch Eruchimovitch | e9cbfc1 | 2011-10-09 19:47:08 +0200 | [diff] [blame] | 29 | #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 Eruchimovitch | e9cbfc1 | 2011-10-09 19:47:08 +0200 | [diff] [blame] | 47 | struct 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 Eruchimovitch | 258b347 | 2012-10-14 21:46:35 +0200 | [diff] [blame] | 55 | /* write index */ |
Baruch Eruchimovitch | e9cbfc1 | 2011-10-09 19:47:08 +0200 | [diff] [blame] | 56 | uint32_t dsp_buf; |
Baruch Eruchimovitch | 258b347 | 2012-10-14 21:46:35 +0200 | [diff] [blame] | 57 | /* read index */ |
Baruch Eruchimovitch | e9cbfc1 | 2011-10-09 19:47:08 +0200 | [diff] [blame] | 58 | 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 Eruchimovitch | 258b347 | 2012-10-14 21:46:35 +0200 | [diff] [blame] | 64 | /* extended parameters, related to q6 variants */ |
Baruch Eruchimovitch | 8c3f780 | 2013-01-05 22:48:04 +0200 | [diff] [blame] | 65 | void *ext; |
Baruch Eruchimovitch | e9cbfc1 | 2011-10-09 19:47:08 +0200 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | struct 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 | |
| 84 | int q6usm_run(struct us_client *usc, uint32_t flags, |
| 85 | uint32_t msw_ts, uint32_t lsw_ts); |
| 86 | int q6usm_cmd(struct us_client *usc, int cmd); |
| 87 | int q6usm_us_client_buf_alloc(unsigned int dir, struct us_client *usc, |
| 88 | unsigned int bufsz, unsigned int bufcnt); |
| 89 | int q6usm_enc_cfg_blk(struct us_client *usc, struct us_encdec_cfg *us_cfg); |
| 90 | int q6usm_dec_cfg_blk(struct us_client *usc, struct us_encdec_cfg *us_cfg); |
| 91 | int q6usm_read(struct us_client *usc, uint32_t read_ind); |
| 92 | struct us_client *q6usm_us_client_alloc( |
| 93 | void (*cb)(uint32_t, uint32_t, uint32_t *, void *), |
| 94 | void *priv); |
| 95 | int q6usm_open_read(struct us_client *usc, uint32_t format); |
| 96 | void q6usm_us_client_free(struct us_client *usc); |
Baruch Eruchimovitch | e9cbfc1 | 2011-10-09 19:47:08 +0200 | [diff] [blame] | 97 | uint32_t q6usm_get_virtual_address(int dir, struct us_client *usc, |
| 98 | struct vm_area_struct *vms); |
Baruch Eruchimovitch | e9cbfc1 | 2011-10-09 19:47:08 +0200 | [diff] [blame] | 99 | int q6usm_open_write(struct us_client *usc, uint32_t format); |
| 100 | int q6usm_write(struct us_client *usc, uint32_t write_ind); |
Baruch Eruchimovitch | 258b347 | 2012-10-14 21:46:35 +0200 | [diff] [blame] | 101 | bool q6usm_is_write_buf_full(struct us_client *usc, uint32_t *free_region); |
Baruch Eruchimovitch | 24dda6a | 2012-01-02 20:28:19 +0200 | [diff] [blame] | 102 | int 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 Eruchimovitch | e9cbfc1 | 2011-10-09 19:47:08 +0200 | [diff] [blame] | 106 | #endif /* __Q6_USM_H__ */ |