Lines Matching refs:mp
43 static void pvr2_context_set_notify(struct pvr2_context *mp, int fl) in pvr2_context_set_notify() argument
48 if (!mp->notify_flag) { in pvr2_context_set_notify()
50 mp->notify_prev = pvr2_context_notify_last; in pvr2_context_set_notify()
51 mp->notify_next = NULL; in pvr2_context_set_notify()
52 pvr2_context_notify_last = mp; in pvr2_context_set_notify()
53 if (mp->notify_prev) { in pvr2_context_set_notify()
54 mp->notify_prev->notify_next = mp; in pvr2_context_set_notify()
56 pvr2_context_notify_first = mp; in pvr2_context_set_notify()
58 mp->notify_flag = !0; in pvr2_context_set_notify()
61 if (mp->notify_flag) { in pvr2_context_set_notify()
62 mp->notify_flag = 0; in pvr2_context_set_notify()
63 if (mp->notify_next) { in pvr2_context_set_notify()
64 mp->notify_next->notify_prev = mp->notify_prev; in pvr2_context_set_notify()
66 pvr2_context_notify_last = mp->notify_prev; in pvr2_context_set_notify()
68 if (mp->notify_prev) { in pvr2_context_set_notify()
69 mp->notify_prev->notify_next = mp->notify_next; in pvr2_context_set_notify()
71 pvr2_context_notify_first = mp->notify_next; in pvr2_context_set_notify()
80 static void pvr2_context_destroy(struct pvr2_context *mp) in pvr2_context_destroy() argument
82 pvr2_trace(PVR2_TRACE_CTXT,"pvr2_context %p (destroy)",mp); in pvr2_context_destroy()
83 if (mp->hdw) pvr2_hdw_destroy(mp->hdw); in pvr2_context_destroy()
84 pvr2_context_set_notify(mp, 0); in pvr2_context_destroy()
86 if (mp->exist_next) { in pvr2_context_destroy()
87 mp->exist_next->exist_prev = mp->exist_prev; in pvr2_context_destroy()
89 pvr2_context_exist_last = mp->exist_prev; in pvr2_context_destroy()
91 if (mp->exist_prev) { in pvr2_context_destroy()
92 mp->exist_prev->exist_next = mp->exist_next; in pvr2_context_destroy()
94 pvr2_context_exist_first = mp->exist_next; in pvr2_context_destroy()
102 kfree(mp); in pvr2_context_destroy()
106 static void pvr2_context_notify(struct pvr2_context *mp) in pvr2_context_notify() argument
108 pvr2_context_set_notify(mp,!0); in pvr2_context_notify()
112 static void pvr2_context_check(struct pvr2_context *mp) in pvr2_context_check() argument
116 "pvr2_context %p (notify)", mp); in pvr2_context_check()
117 if (!mp->initialized_flag && !mp->disconnect_flag) { in pvr2_context_check()
118 mp->initialized_flag = !0; in pvr2_context_check()
120 "pvr2_context %p (initialize)", mp); in pvr2_context_check()
122 if (pvr2_hdw_initialize(mp->hdw, in pvr2_context_check()
124 mp)) { in pvr2_context_check()
125 mp->video_stream.stream = in pvr2_context_check()
126 pvr2_hdw_get_video_stream(mp->hdw); in pvr2_context_check()
130 if (mp->setup_func) mp->setup_func(mp); in pvr2_context_check()
134 mp); in pvr2_context_check()
143 for (ch1 = mp->mc_first; ch1; ch1 = ch2) { in pvr2_context_check()
148 if (mp->disconnect_flag && !mp->mc_first) { in pvr2_context_check()
150 pvr2_context_destroy(mp); in pvr2_context_check()
164 struct pvr2_context *mp; in pvr2_context_thread_func() local
169 while ((mp = pvr2_context_notify_first) != NULL) { in pvr2_context_thread_func()
170 pvr2_context_set_notify(mp, 0); in pvr2_context_thread_func()
171 pvr2_context_check(mp); in pvr2_context_thread_func()
219 struct pvr2_context *mp = NULL; in pvr2_context_create() local
220 mp = kzalloc(sizeof(*mp),GFP_KERNEL); in pvr2_context_create()
221 if (!mp) goto done; in pvr2_context_create()
222 pvr2_trace(PVR2_TRACE_CTXT,"pvr2_context %p (create)",mp); in pvr2_context_create()
223 mp->setup_func = setup_func; in pvr2_context_create()
224 mutex_init(&mp->mutex); in pvr2_context_create()
226 mp->exist_prev = pvr2_context_exist_last; in pvr2_context_create()
227 mp->exist_next = NULL; in pvr2_context_create()
228 pvr2_context_exist_last = mp; in pvr2_context_create()
229 if (mp->exist_prev) { in pvr2_context_create()
230 mp->exist_prev->exist_next = mp; in pvr2_context_create()
232 pvr2_context_exist_first = mp; in pvr2_context_create()
235 mp->hdw = pvr2_hdw_create(intf,devid); in pvr2_context_create()
236 if (!mp->hdw) { in pvr2_context_create()
237 pvr2_context_destroy(mp); in pvr2_context_create()
238 mp = NULL; in pvr2_context_create()
241 pvr2_context_set_notify(mp, !0); in pvr2_context_create()
243 return mp; in pvr2_context_create()
247 static void pvr2_context_reset_input_limits(struct pvr2_context *mp) in pvr2_context_reset_input_limits() argument
251 struct pvr2_hdw *hdw = mp->hdw; in pvr2_context_reset_input_limits()
254 for (cp = mp->mc_first; cp; cp = cp->mc_next) { in pvr2_context_reset_input_limits()
263 static void pvr2_context_enter(struct pvr2_context *mp) in pvr2_context_enter() argument
265 mutex_lock(&mp->mutex); in pvr2_context_enter()
269 static void pvr2_context_exit(struct pvr2_context *mp) in pvr2_context_exit() argument
272 if (!(mp->mc_first || !mp->disconnect_flag)) { in pvr2_context_exit()
275 mutex_unlock(&mp->mutex); in pvr2_context_exit()
276 if (destroy_flag) pvr2_context_notify(mp); in pvr2_context_exit()
280 void pvr2_context_disconnect(struct pvr2_context *mp) in pvr2_context_disconnect() argument
282 pvr2_hdw_disconnect(mp->hdw); in pvr2_context_disconnect()
283 mp->disconnect_flag = !0; in pvr2_context_disconnect()
284 pvr2_context_notify(mp); in pvr2_context_disconnect()
288 void pvr2_channel_init(struct pvr2_channel *cp,struct pvr2_context *mp) in pvr2_channel_init() argument
290 pvr2_context_enter(mp); in pvr2_channel_init()
291 cp->hdw = mp->hdw; in pvr2_channel_init()
292 cp->mc_head = mp; in pvr2_channel_init()
294 cp->mc_prev = mp->mc_last; in pvr2_channel_init()
295 if (mp->mc_last) { in pvr2_channel_init()
296 mp->mc_last->mc_next = cp; in pvr2_channel_init()
298 mp->mc_first = cp; in pvr2_channel_init()
300 mp->mc_last = cp; in pvr2_channel_init()
301 pvr2_context_exit(mp); in pvr2_channel_init()
316 struct pvr2_context *mp = cp->mc_head; in pvr2_channel_done() local
317 pvr2_context_enter(mp); in pvr2_channel_done()
320 pvr2_context_reset_input_limits(mp); in pvr2_channel_done()
324 mp->mc_last = cp->mc_prev; in pvr2_channel_done()
329 mp->mc_first = cp->mc_next; in pvr2_channel_done()
332 pvr2_context_exit(mp); in pvr2_channel_done()