aboutsummaryrefslogtreecommitdiff
path: root/drivers/media/radio/CG2900/platformosapi.h
blob: e677bf0d1a0c5459781dadbd6ac2b1d4f038de24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/*
 * Copyright (C) ST-Ericsson SA 2010
 *
 * Linux Platform and OS Dependent File for FM Driver
 *
 * Author: Hemant Gupta/hemant.gupta@stericsson.com for ST-Ericsson.
 *
 * License terms: GNU General Public License (GPL), version 2
 */

#ifndef PLATFORM_OSAPI_H
#define PLATFORM_OSAPI_H

#include <linux/module.h>	/* Modules                        */
#include <linux/init.h>		/* Initdata                       */
#include <linux/uaccess.h>	/* copy to/from user              */
#include <linux/smp_lock.h>	/* Lock & Unlock Kernel		  */
#include <linux/semaphore.h>	/* Semaphores */
#include <linux/version.h>      /* for KERNEL_VERSION MACRO     */
#include <linux/kthread.h>      /* for Kernel Thread  */
#include <linux/kernel.h>      /* for KERNEL */
#include <linux/timer.h>
#include <linux/mutex.h>
#include "stefmapi.h"

/* module_param declared in platformosapi.c */
extern unsigned short ste_fm_debug_level;

#define FM_DEBUG_REPORT(fmt, arg...) \
	if (ste_fm_debug_level > 2) { \
		printk(KERN_INFO "CG2900_FM_Driver: " fmt "\r\n" , ## arg); \
	}

#define FM_INFO_REPORT(fmt, arg...)    \
	if (ste_fm_debug_level > 1) { \
		printk(KERN_INFO "CG2900_FM_Driver: " fmt "\r\n" , ## arg); \
	}

#define FM_ERR_REPORT(fmt, arg...)               \
	if (ste_fm_debug_level > 0) { \
		printk(KERN_ERR "CG2900_FM_Driver: " fmt "\r\n" , ## arg); \
	}

/**
 * os_fm_driver_init()- Initializes the Mutex, Semaphore, etc for FM Driver.
 *
 * It also registes FM Driver with the Protocol Driver.
 *
 * Returns:
 *   1 if initialization fails, else 0 on success.
 */
int os_fm_driver_init(void);

/**
 * os_fm_driver_deinit() - Deinitializes the mutex, semaphores, etc.
 *
 * It also deregistes FM Driver with the Protocol Driver.
 *
 */
void os_fm_driver_deinit(void);


/**
 * os_mem_alloc() - Allocates requested bytes to a pointer.
 * @num_bytes: Number of bytes to be allocated.
 *
 * Returns:
 *   Pointer pointing to the memory allocated.
 */
void *os_mem_alloc(
		u32 num_bytes
		);

/**
 * os_mem_free() - Frees the memory allocated to a pointer
 * @free_ptr: Pointer to the Memory to be freed.
 */
void os_mem_free(
		void *free_ptr
		);

/**
 * os_mem_copy() - Copy memory of fixed bytes from Source to Destination.
 * @dest: Memory location where the data has to be copied.
 * @src: Memory location from where the data hasto be copied.
 * @num_bytes: Number of bytes to be copied from Source pointer to
 * Destination pointer.
 */
void os_mem_copy(
		void *dest,
		void *src,
		u32 num_bytes
		);

/**
 * os_sleep() - Suspends the current task for a specified time
 * @milli_sec: Time in ms to suspend the task
 */
void os_sleep(
		u32 milli_sec
		);

/**
 * os_lock() - Enter Critical Section
 */
void os_lock(void);

/**
 * os_unlock() - Leave Critical Section
 */
void os_unlock(void);

/**
 * os_get_cmd_sem() - Block on Command Semaphore.
 * This is required to ensure Flow Control in FM Driver.
 */
void os_get_cmd_sem(void);

/**
 * os_set_cmd_sem() - Unblock on Command Semaphore.
 * This is required to ensure Flow Control in FM Driver.
 */
void os_set_cmd_sem(void);

/**
 * os_get_hal_sem() - Block on HAL Semaphore.
 * This is required to ensure Flow Control in FM Driver.
 */
void os_get_hal_sem(void);

/**
 * os_set_hal_sem() - Unblock on HAL Semaphore.
 * This is required to ensure Flow Control in FM Driver.
 */
void os_set_hal_sem(void);

/**
 * os_get_read_response_sem() - Block on fmd_read_resp Semaphore.
 * This semaphore is blocked till the command complete event is
 * received from FM Chip for the last command sent.
 */
void os_get_read_response_sem(void);

/**
 * os_set_read_response_sem() - Unblock on fmd_read_resp Semaphore.
 * This semaphore is unblocked on receiving command complete event
 * from FM Chip for the last command sent.
 */
void os_set_read_response_sem(void);

/**
 * os_get_rds_sem() - Block on RDS Semaphore.
 * Till irpt_BufferFull is received, RDS Task is blocked.
 */
void os_get_rds_sem(void);

/**
 * os_set_rds_sem() - Unblock on RDS Semaphore.
 * on receiving  irpt_BufferFull, RDS Task is un-blocked.
 */
void os_set_rds_sem(void);

/**
 * os_get_interrupt_sem() - Block on Interrupt Semaphore.
 * Till Interrupt is received, Interrupt Task is blocked.
 */
void os_get_interrupt_sem(void);

/**
 * os_set_interrupt_sem() - Unblock on Interrupt Semaphore.
 * on receiving  Interrupt, Interrupt Task is un-blocked.
 */
void os_set_interrupt_sem(void);

/**
 * os_start_rds_thread() - Starts the RDS Thread for receiving RDS Data.
 * This is started by Application when it wants to receive RDS Data.
 * @cb_func: Callback function for receiving RDS Data
 */
void os_start_rds_thread(
		ste_fm_rds_cb cb_func
		);

/**
 * os_stop_rds_thread() - Stops the RDS Thread when Application does not
 * want to receive RDS.
 */
void os_stop_rds_thread(void);

/**
 * ste_fm_send_packet() - Sends the FM HCI Packet to the STE Protocol Driver.
 * @num_bytes: Number of bytes of Data to be sent including
 * Channel Identifier (08)
 * @send_buffer: Buffer containing the Data to be sent to Chip.
 *
 * Returns:
 * 0 if packet was sent successfully to STE Protocol Driver, otherwise the
 * corresponding error.
 */
int ste_fm_send_packet(
		u16 num_bytes,
		u8 *send_buffer
		);

#endif /* PLATFORM_OSAPI_H */