68
68
****************************************************************************/
69
69
70
70
/* Debug ********************************************************************/
71
+
71
72
/* Non-standard debug that may be enabled just for testing Audio */
72
73
73
74
#ifndef AUDIO_MAX_DEVICE_PATH
86
87
87
88
struct audio_upperhalf_s
88
89
{
89
- uint8_t crefs ; /* The number of times the device has been opened */
90
- volatile bool started ; /* True: playback is active */
91
- sem_t exclsem ; /* Supports mutual exclusion */
90
+ uint8_t crefs ; /* The number of times the device has been opened */
91
+ volatile bool started ; /* True: playback is active */
92
+ sem_t exclsem ; /* Supports mutual exclusion */
92
93
FAR struct audio_lowerhalf_s * dev ; /* lower-half state */
93
- mqd_t usermq ; /* User mode app's message queue */
94
+ mqd_t usermq ; /* User mode app's message queue */
94
95
};
95
96
96
97
/****************************************************************************
@@ -99,17 +100,29 @@ struct audio_upperhalf_s
99
100
100
101
static int audio_open (FAR struct file * filep );
101
102
static int audio_close (FAR struct file * filep );
102
- static ssize_t audio_read (FAR struct file * filep , FAR char * buffer , size_t buflen );
103
- static ssize_t audio_write (FAR struct file * filep , FAR const char * buffer , size_t buflen );
104
- static int audio_ioctl (FAR struct file * filep , int cmd , unsigned long arg );
103
+ static ssize_t audio_read (FAR struct file * filep ,
104
+ FAR char * buffer ,
105
+ size_t buflen );
106
+ static ssize_t audio_write (FAR struct file * filep ,
107
+ FAR const char * buffer ,
108
+ size_t buflen );
109
+ static int audio_ioctl (FAR struct file * filep ,
110
+ int cmd ,
111
+ unsigned long arg );
105
112
#ifdef CONFIG_AUDIO_MULTI_SESSION
106
- static int audio_start (FAR struct audio_upperhalf_s * upper , FAR void * session );
107
- static void audio_callback (FAR void * priv , uint16_t reason ,
108
- FAR struct ap_buffer_s * apb , uint16_t status , FAR void * session );
113
+ static int audio_start (FAR struct audio_upperhalf_s * upper ,
114
+ FAR void * session );
115
+ static void audio_callback (FAR void * priv ,
116
+ uint16_t reason ,
117
+ FAR struct ap_buffer_s * apb ,
118
+ uint16_t status ,
119
+ FAR void * session );
109
120
#else
110
121
static int audio_start (FAR struct audio_upperhalf_s * upper );
111
- static void audio_callback (FAR void * priv , uint16_t reason ,
112
- FAR struct ap_buffer_s * apb , uint16_t status );
122
+ static void audio_callback (FAR void * priv ,
123
+ uint16_t reason ,
124
+ FAR struct ap_buffer_s * apb ,
125
+ uint16_t status );
113
126
#endif /* CONFIG_AUDIO_MULTI_SESSION */
114
127
115
128
/****************************************************************************
@@ -131,13 +144,13 @@ static const struct file_operations g_audioops =
131
144
* Private Functions
132
145
****************************************************************************/
133
146
134
- /************************************************************************************
147
+ /****************************************************************************
135
148
* Name: audio_open
136
149
*
137
150
* Description:
138
151
* This function is called whenever the Audio device is opened.
139
152
*
140
- ************************************************************************************ /
153
+ ****************************************************************************/
141
154
142
155
static int audio_open (FAR struct file * filep )
143
156
{
@@ -184,13 +197,13 @@ static int audio_open(FAR struct file *filep)
184
197
return ret ;
185
198
}
186
199
187
- /************************************************************************************
200
+ /****************************************************************************
188
201
* Name: audio_close
189
202
*
190
203
* Description:
191
204
* This function is called when the Audio device is closed.
192
205
*
193
- ************************************************************************************ /
206
+ ****************************************************************************/
194
207
195
208
static int audio_close (FAR struct file * filep )
196
209
{
@@ -241,15 +254,17 @@ static int audio_close(FAR struct file *filep)
241
254
return ret ;
242
255
}
243
256
244
- /************************************************************************************
257
+ /****************************************************************************
245
258
* Name: audio_read
246
259
*
247
260
* Description:
248
261
* A dummy read method. This is provided only to satsify the VFS layer.
249
262
*
250
- ************************************************************************************ /
263
+ ****************************************************************************/
251
264
252
- static ssize_t audio_read (FAR struct file * filep , FAR char * buffer , size_t buflen )
265
+ static ssize_t audio_read (FAR struct file * filep ,
266
+ FAR char * buffer ,
267
+ size_t buflen )
253
268
{
254
269
FAR struct inode * inode = filep -> f_inode ;
255
270
FAR struct audio_upperhalf_s * upper = inode -> i_private ;
@@ -267,15 +282,17 @@ static ssize_t audio_read(FAR struct file *filep, FAR char *buffer, size_t bufle
267
282
return 0 ;
268
283
}
269
284
270
- /************************************************************************************
285
+ /****************************************************************************
271
286
* Name: audio_write
272
287
*
273
288
* Description:
274
289
* A dummy write method. This is provided only to satsify the VFS layer.
275
290
*
276
- ************************************************************************************ /
291
+ ****************************************************************************/
277
292
278
- static ssize_t audio_write (FAR struct file * filep , FAR const char * buffer , size_t buflen )
293
+ static ssize_t audio_write (FAR struct file * filep ,
294
+ FAR const char * buffer ,
295
+ size_t buflen )
279
296
{
280
297
FAR struct inode * inode = filep -> f_inode ;
281
298
FAR struct audio_upperhalf_s * upper = inode -> i_private ;
@@ -293,16 +310,17 @@ static ssize_t audio_write(FAR struct file *filep, FAR const char *buffer, size_
293
310
return 0 ;
294
311
}
295
312
296
- /************************************************************************************
313
+ /****************************************************************************
297
314
* Name: audio_start
298
315
*
299
316
* Description:
300
317
* Handle the AUDIOIOC_START ioctl command
301
318
*
302
- ************************************************************************************ /
319
+ ****************************************************************************/
303
320
304
321
#ifdef CONFIG_AUDIO_MULTI_SESSION
305
- static int audio_start (FAR struct audio_upperhalf_s * upper , FAR void * session )
322
+ static int audio_start (FAR struct audio_upperhalf_s * upper ,
323
+ FAR void * session )
306
324
#else
307
325
static int audio_start (FAR struct audio_upperhalf_s * upper )
308
326
#endif
@@ -339,13 +357,13 @@ static int audio_start(FAR struct audio_upperhalf_s *upper)
339
357
return ret ;
340
358
}
341
359
342
- /************************************************************************************
360
+ /****************************************************************************
343
361
* Name: audio_ioctl
344
362
*
345
363
* Description:
346
364
* The standard ioctl method. This is where ALL of the Audio work is done.
347
365
*
348
- ************************************************************************************ /
366
+ ****************************************************************************/
349
367
350
368
static int audio_ioctl (FAR struct file * filep , int cmd , unsigned long arg )
351
369
{
@@ -379,7 +397,8 @@ static int audio_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
379
397
380
398
case AUDIOIOC_GETCAPS :
381
399
{
382
- FAR struct audio_caps_s * caps = (FAR struct audio_caps_s * )((uintptr_t )arg );
400
+ FAR struct audio_caps_s * caps =
401
+ (FAR struct audio_caps_s * )((uintptr_t )arg );
383
402
DEBUGASSERT (lower -> ops -> getcaps != NULL );
384
403
385
404
audinfo ("AUDIOIOC_GETCAPS: Device=%d\n" , caps -> ac_type );
@@ -420,7 +439,8 @@ static int audio_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
420
439
}
421
440
break ;
422
441
423
- /* AUDIOIOC_START - Start the audio stream. The AUDIOIOC_SETCHARACTERISTICS
442
+ /* AUDIOIOC_START - Start the audio stream.
443
+ * The AUDIOIOC_SETCHARACTERISTICS
424
444
* command must have previously been sent.
425
445
*
426
446
* ioctl argument: Audio session
@@ -647,7 +667,9 @@ static int audio_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
647
667
}
648
668
break ;
649
669
650
- /* Any unrecognized IOCTL commands might be platform-specific ioctl commands */
670
+ /* Any unrecognized IOCTL commands might be
671
+ * platform-specific ioctl commands
672
+ */
651
673
652
674
default :
653
675
{
@@ -711,8 +733,8 @@ static inline void audio_dequeuebuffer(FAR struct audio_upperhalf_s *upper,
711
733
712
734
if (upper -> usermq != NULL )
713
735
{
714
- msg .msgId = AUDIO_MSG_DEQUEUE ;
715
- msg .u .pPtr = apb ;
736
+ msg .msg_id = AUDIO_MSG_DEQUEUE ;
737
+ msg .u .ptr = apb ;
716
738
#ifdef CONFIG_AUDIO_MULTI_SESSION
717
739
msg .session = session ;
718
740
#endif
@@ -750,8 +772,8 @@ static inline void audio_complete(FAR struct audio_upperhalf_s *upper,
750
772
upper -> started = false;
751
773
if (upper -> usermq != NULL )
752
774
{
753
- msg .msgId = AUDIO_MSG_COMPLETE ;
754
- msg .u .pPtr = NULL ;
775
+ msg .msg_id = AUDIO_MSG_COMPLETE ;
776
+ msg .u .ptr = NULL ;
755
777
#ifdef CONFIG_AUDIO_MULTI_SESSION
756
778
msg .session = session ;
757
779
#endif
@@ -823,7 +845,8 @@ static void audio_callback(FAR void *handle, uint16_t reason,
823
845
FAR struct ap_buffer_s * apb , uint16_t status )
824
846
#endif
825
847
{
826
- FAR struct audio_upperhalf_s * upper = (FAR struct audio_upperhalf_s * )handle ;
848
+ FAR struct audio_upperhalf_s * upper =
849
+ (FAR struct audio_upperhalf_s * )handle ;
827
850
828
851
audinfo ("Entry\n" );
829
852
@@ -854,7 +877,9 @@ static void audio_callback(FAR void *handle, uint16_t reason,
854
877
855
878
case AUDIO_CALLBACK_COMPLETE :
856
879
{
857
- /* Send a complete message to the user if a message queue is registered */
880
+ /* Send a complete message to the user if a message queue
881
+ * is registered
882
+ */
858
883
859
884
#ifdef CONFIG_AUDIO_MULTI_SESSION
860
885
audio_complete (upper , apb , status , session );
@@ -902,9 +927,9 @@ static void audio_callback(FAR void *handle, uint16_t reason,
902
927
* filesystem. The recommended convention is to name Audio drivers
903
928
* based on the function they provide, such as "/dev/pcm0", "/dev/mp31",
904
929
* etc.
905
- * dev - A pointer to an instance of lower half audio driver. This instance
906
- * is bound to the Audio driver and must persists as long as the driver
907
- * persists.
930
+ * dev - A pointer to an instance of lower half audio driver.
931
+ * This instance is bound to the Audio driver and must persists as long
932
+ * as the driver persists.
908
933
*
909
934
* Returned Value:
910
935
* Zero on success; a negated errno value on failure.
@@ -926,14 +951,17 @@ int audio_register(FAR const char *name, FAR struct audio_lowerhalf_s *dev)
926
951
927
952
/* Allocate the upper-half data structure */
928
953
929
- upper = (FAR struct audio_upperhalf_s * )kmm_zalloc (sizeof (struct audio_upperhalf_s ));
954
+ upper = (FAR struct audio_upperhalf_s * )kmm_zalloc (
955
+ sizeof (struct audio_upperhalf_s ));
930
956
if (!upper )
931
957
{
932
958
auderr ("ERROR: Allocation failed\n" );
933
959
return - ENOMEM ;
934
960
}
935
961
936
- /* Initialize the Audio device structure (it was already zeroed by kmm_zalloc()) */
962
+ /* Initialize the Audio device structure
963
+ * (it was already zeroed by kmm_zalloc())
964
+ */
937
965
938
966
nxsem_init (& upper -> exclsem , 0 , 1 );
939
967
upper -> dev = dev ;
@@ -979,6 +1007,7 @@ int audio_register(FAR const char *name, FAR struct audio_lowerhalf_s *dev)
979
1007
{
980
1008
* pathptr ++ = * ptr ++ ;
981
1009
}
1010
+
982
1011
* pathptr = '\0' ;
983
1012
984
1013
/* Make this level of directory */
0 commit comments