1 #include <minix/audio_fw.h>
6 * EXTERN sub_dev_t sub_dev[];
9 /* State management helpers */
10 static int is_read_pending
;
11 static int is_write_pending
;
12 static void load_state_info(void)
14 int i
, dma_mode
, found_pending
;
16 /* Check if reads or writes are pending. */
17 is_read_pending
= FALSE
;
18 is_write_pending
= FALSE
;
19 found_pending
= FALSE
;
20 for (i
= 0; i
< drv
.NrOfSubDevices
&& !found_pending
; i
++) {
21 if(sub_dev
[i
].RevivePending
) {
22 dma_mode
= sub_dev
[i
].DmaMode
;
24 if(dma_mode
== READ_DMA
) {
25 is_read_pending
= TRUE
;
27 else if (dma_mode
== WRITE_DMA
){
28 is_write_pending
= TRUE
;
32 found_pending
= (is_read_pending
&& is_write_pending
);
36 /* Custom states definition. */
37 #define AUDIO_STATE_READ_REQUEST_FREE (SEF_LU_STATE_CUSTOM_BASE + 0)
38 #define AUDIO_STATE_WRITE_REQUEST_FREE (SEF_LU_STATE_CUSTOM_BASE + 1)
39 #define AUDIO_STATE_IS_CUSTOM(s) \
40 ((s) >= AUDIO_STATE_READ_REQUEST_FREE && (s) <=AUDIO_STATE_WRITE_REQUEST_FREE)
42 /*===========================================================================*
44 *===========================================================================*/
45 int sef_cb_lu_prepare(int state
)
49 /* Load state information. */
52 /* Check if we are ready for the target state. */
55 /* Standard states. */
56 case SEF_LU_STATE_REQUEST_FREE
:
57 is_ready
= (!is_read_pending
&& !is_write_pending
);
60 case SEF_LU_STATE_PROTOCOL_FREE
:
61 is_ready
= (!is_read_pending
&& !is_write_pending
);
65 case AUDIO_STATE_READ_REQUEST_FREE
:
66 is_ready
= (!is_read_pending
);
69 case AUDIO_STATE_WRITE_REQUEST_FREE
:
70 is_ready
= (!is_write_pending
);
74 /* Tell SEF if we are ready. */
75 return is_ready
? OK
: ENOTREADY
;
78 /*===========================================================================*
79 * sef_cb_lu_state_isvalid *
80 *===========================================================================*/
81 int sef_cb_lu_state_isvalid(int state
)
83 return SEF_LU_STATE_IS_STANDARD(state
) || AUDIO_STATE_IS_CUSTOM(state
);
86 /*===========================================================================*
87 * sef_cb_lu_state_dump *
88 *===========================================================================*/
89 void sef_cb_lu_state_dump(int state
)
91 /* Load state information. */
94 sef_lu_dprint("audio: live update state = %d\n", state
);
95 sef_lu_dprint("audio: is_read_pending = %d\n", is_read_pending
);
96 sef_lu_dprint("audio: is_write_pending = %d\n", is_write_pending
);
98 sef_lu_dprint("audio: SEF_LU_STATE_WORK_FREE(%d) reached = %d\n",
99 SEF_LU_STATE_WORK_FREE
, TRUE
);
100 sef_lu_dprint("audio: SEF_LU_STATE_REQUEST_FREE(%d) reached = %d\n",
101 SEF_LU_STATE_REQUEST_FREE
, (!is_read_pending
&& !is_write_pending
));
102 sef_lu_dprint("audio: SEF_LU_STATE_PROTOCOL_FREE(%d) reached = %d\n",
103 SEF_LU_STATE_PROTOCOL_FREE
, (!is_read_pending
&& !is_write_pending
));
104 sef_lu_dprint("audio: AUDIO_STATE_READ_REQUEST_FREE(%d) reached = %d\n",
105 AUDIO_STATE_READ_REQUEST_FREE
, (!is_read_pending
));
106 sef_lu_dprint("audio: AUDIO_STATE_WRITE_REQUEST_FREE(%d) reached = %d\n",
107 AUDIO_STATE_WRITE_REQUEST_FREE
, (!is_write_pending
));