Lines Matching refs:dev
85 static void vivid_thread_sdr_cap_tick(struct vivid_dev *dev) in vivid_thread_sdr_cap_tick() argument
89 dprintk(dev, 1, "SDR Capture Thread Tick\n"); in vivid_thread_sdr_cap_tick()
92 if (dev->perc_dropped_buffers && in vivid_thread_sdr_cap_tick()
93 get_random_u32_below(100) < dev->perc_dropped_buffers) in vivid_thread_sdr_cap_tick()
96 spin_lock(&dev->slock); in vivid_thread_sdr_cap_tick()
97 if (!list_empty(&dev->sdr_cap_active)) { in vivid_thread_sdr_cap_tick()
98 sdr_cap_buf = list_entry(dev->sdr_cap_active.next, in vivid_thread_sdr_cap_tick()
102 spin_unlock(&dev->slock); in vivid_thread_sdr_cap_tick()
105 sdr_cap_buf->vb.sequence = dev->sdr_cap_with_seq_wrap_count; in vivid_thread_sdr_cap_tick()
107 &dev->ctrl_hdl_sdr_cap); in vivid_thread_sdr_cap_tick()
109 &dev->ctrl_hdl_sdr_cap); in vivid_thread_sdr_cap_tick()
110 vivid_sdr_cap_process(dev, sdr_cap_buf); in vivid_thread_sdr_cap_tick()
112 ktime_get_ns() + dev->time_wrap_offset; in vivid_thread_sdr_cap_tick()
113 vb2_buffer_done(&sdr_cap_buf->vb.vb2_buf, dev->dqbuf_error ? in vivid_thread_sdr_cap_tick()
115 dev->dqbuf_error = false; in vivid_thread_sdr_cap_tick()
121 struct vivid_dev *dev = data; in vivid_thread_sdr_cap() local
129 dprintk(dev, 1, "SDR Capture Thread Start\n"); in vivid_thread_sdr_cap()
134 dev->sdr_cap_seq_offset = 0; in vivid_thread_sdr_cap()
135 dev->sdr_cap_seq_count = 0; in vivid_thread_sdr_cap()
136 dev->jiffies_sdr_cap = jiffies; in vivid_thread_sdr_cap()
137 dev->sdr_cap_seq_resync = false; in vivid_thread_sdr_cap()
138 if (dev->time_wrap) in vivid_thread_sdr_cap()
139 dev->time_wrap_offset = dev->time_wrap - ktime_get_ns(); in vivid_thread_sdr_cap()
141 dev->time_wrap_offset = 0; in vivid_thread_sdr_cap()
148 if (!mutex_trylock(&dev->mutex)) { in vivid_thread_sdr_cap()
154 if (dev->sdr_cap_seq_resync) { in vivid_thread_sdr_cap()
155 dev->jiffies_sdr_cap = cur_jiffies; in vivid_thread_sdr_cap()
156 dev->sdr_cap_seq_offset = dev->sdr_cap_seq_count + 1; in vivid_thread_sdr_cap()
157 dev->sdr_cap_seq_count = 0; in vivid_thread_sdr_cap()
158 dev->sdr_cap_seq_resync = false; in vivid_thread_sdr_cap()
161 jiffies_since_start = cur_jiffies - dev->jiffies_sdr_cap; in vivid_thread_sdr_cap()
164 (u64)jiffies_since_start * dev->sdr_adc_freq + in vivid_thread_sdr_cap()
175 dev->jiffies_sdr_cap = cur_jiffies; in vivid_thread_sdr_cap()
176 dev->sdr_cap_seq_offset = buffers_since_start; in vivid_thread_sdr_cap()
179 dev->sdr_cap_seq_count = in vivid_thread_sdr_cap()
180 buffers_since_start + dev->sdr_cap_seq_offset; in vivid_thread_sdr_cap()
181 dev->sdr_cap_with_seq_wrap_count = dev->sdr_cap_seq_count - dev->sdr_cap_seq_start; in vivid_thread_sdr_cap()
183 vivid_thread_sdr_cap_tick(dev); in vivid_thread_sdr_cap()
184 mutex_unlock(&dev->mutex); in vivid_thread_sdr_cap()
193 jiffies_since_start = jiffies - dev->jiffies_sdr_cap; in vivid_thread_sdr_cap()
202 dev->sdr_adc_freq / 2; in vivid_thread_sdr_cap()
203 do_div(next_jiffies_since_start, dev->sdr_adc_freq); in vivid_thread_sdr_cap()
213 dprintk(dev, 1, "SDR Capture Thread End\n"); in vivid_thread_sdr_cap()
229 struct vivid_dev *dev = vb2_get_drv_priv(vb->vb2_queue); in sdr_cap_buf_prepare() local
232 dprintk(dev, 1, "%s\n", __func__); in sdr_cap_buf_prepare()
234 if (dev->buf_prepare_error) { in sdr_cap_buf_prepare()
239 dev->buf_prepare_error = false; in sdr_cap_buf_prepare()
243 dprintk(dev, 1, "%s data will not fit into plane (%lu < %u)\n", in sdr_cap_buf_prepare()
255 struct vivid_dev *dev = vb2_get_drv_priv(vb->vb2_queue); in sdr_cap_buf_queue() local
258 dprintk(dev, 1, "%s\n", __func__); in sdr_cap_buf_queue()
260 spin_lock(&dev->slock); in sdr_cap_buf_queue()
261 list_add_tail(&buf->list, &dev->sdr_cap_active); in sdr_cap_buf_queue()
262 spin_unlock(&dev->slock); in sdr_cap_buf_queue()
267 struct vivid_dev *dev = vb2_get_drv_priv(vq); in sdr_cap_start_streaming() local
270 dprintk(dev, 1, "%s\n", __func__); in sdr_cap_start_streaming()
271 dev->sdr_cap_seq_start = dev->seq_wrap * 128; in sdr_cap_start_streaming()
272 if (dev->start_streaming_error) { in sdr_cap_start_streaming()
273 dev->start_streaming_error = false; in sdr_cap_start_streaming()
275 } else if (dev->kthread_sdr_cap == NULL) { in sdr_cap_start_streaming()
276 dev->kthread_sdr_cap = kthread_run(vivid_thread_sdr_cap, dev, in sdr_cap_start_streaming()
277 "%s-sdr-cap", dev->v4l2_dev.name); in sdr_cap_start_streaming()
279 if (IS_ERR(dev->kthread_sdr_cap)) { in sdr_cap_start_streaming()
280 v4l2_err(&dev->v4l2_dev, "kernel_thread() failed\n"); in sdr_cap_start_streaming()
281 err = PTR_ERR(dev->kthread_sdr_cap); in sdr_cap_start_streaming()
282 dev->kthread_sdr_cap = NULL; in sdr_cap_start_streaming()
288 list_for_each_entry_safe(buf, tmp, &dev->sdr_cap_active, list) { in sdr_cap_start_streaming()
300 struct vivid_dev *dev = vb2_get_drv_priv(vq); in sdr_cap_stop_streaming() local
302 if (dev->kthread_sdr_cap == NULL) in sdr_cap_stop_streaming()
305 while (!list_empty(&dev->sdr_cap_active)) { in sdr_cap_stop_streaming()
308 buf = list_entry(dev->sdr_cap_active.next, in sdr_cap_stop_streaming()
312 &dev->ctrl_hdl_sdr_cap); in sdr_cap_stop_streaming()
317 kthread_stop(dev->kthread_sdr_cap); in sdr_cap_stop_streaming()
318 dev->kthread_sdr_cap = NULL; in sdr_cap_stop_streaming()
323 struct vivid_dev *dev = vb2_get_drv_priv(vb->vb2_queue); in sdr_cap_buf_request_complete() local
325 v4l2_ctrl_request_complete(vb->req_obj.req, &dev->ctrl_hdl_sdr_cap); in sdr_cap_buf_request_complete()
361 struct vivid_dev *dev = video_drvdata(file); in vivid_sdr_g_frequency() local
365 vf->frequency = dev->sdr_adc_freq; in vivid_sdr_g_frequency()
369 vf->frequency = dev->sdr_fm_freq; in vivid_sdr_g_frequency()
380 struct vivid_dev *dev = video_drvdata(file); in vivid_sdr_s_frequency() local
399 if (vb2_is_streaming(&dev->vb_sdr_cap_q) && in vivid_sdr_s_frequency()
400 freq != dev->sdr_adc_freq) { in vivid_sdr_s_frequency()
402 dev->sdr_cap_seq_resync = true; in vivid_sdr_s_frequency()
404 dev->sdr_adc_freq = freq; in vivid_sdr_s_frequency()
409 dev->sdr_fm_freq = clamp_t(unsigned, freq, in vivid_sdr_s_frequency()
459 struct vivid_dev *dev = video_drvdata(file); in vidioc_g_fmt_sdr_cap() local
461 f->fmt.sdr.pixelformat = dev->sdr_pixelformat; in vidioc_g_fmt_sdr_cap()
462 f->fmt.sdr.buffersize = dev->sdr_buffersize; in vidioc_g_fmt_sdr_cap()
468 struct vivid_dev *dev = video_drvdata(file); in vidioc_s_fmt_sdr_cap() local
469 struct vb2_queue *q = &dev->vb_sdr_cap_q; in vidioc_s_fmt_sdr_cap()
477 dev->sdr_pixelformat = formats[i].pixelformat; in vidioc_s_fmt_sdr_cap()
478 dev->sdr_buffersize = formats[i].buffersize; in vidioc_s_fmt_sdr_cap()
483 dev->sdr_pixelformat = formats[0].pixelformat; in vidioc_s_fmt_sdr_cap()
484 dev->sdr_buffersize = formats[0].buffersize; in vidioc_s_fmt_sdr_cap()
510 void vivid_sdr_cap_process(struct vivid_dev *dev, struct vivid_buffer *buf) in vivid_sdr_cap_process() argument
524 dev->sdr_adc_freq); in vivid_sdr_cap_process()
527 mod_phase_step = fixp_cos32_rad(dev->sdr_fixp_src_phase, in vivid_sdr_cap_process()
530 dev->sdr_fixp_src_phase += src_phase_step; in vivid_sdr_cap_process()
531 s64tmp = (s64) mod_phase_step * dev->sdr_fm_deviation; in vivid_sdr_cap_process()
532 dev->sdr_fixp_mod_phase += div_s64(s64tmp, M_100000PI); in vivid_sdr_cap_process()
539 dev->sdr_fixp_src_phase %= FIXP_2PI; in vivid_sdr_cap_process()
540 dev->sdr_fixp_mod_phase %= FIXP_2PI; in vivid_sdr_cap_process()
542 if (dev->sdr_fixp_mod_phase < 0) in vivid_sdr_cap_process()
543 dev->sdr_fixp_mod_phase += FIXP_2PI; in vivid_sdr_cap_process()
545 fixp_i = fixp_cos32_rad(dev->sdr_fixp_mod_phase, FIXP_2PI); in vivid_sdr_cap_process()
546 fixp_q = fixp_sin32_rad(dev->sdr_fixp_mod_phase, FIXP_2PI); in vivid_sdr_cap_process()
553 switch (dev->sdr_pixelformat) { in vivid_sdr_cap_process()