1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * vivid-core.h - core datastructures
4 *
5 * Copyright 2014 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
6 */
7
8 #ifndef _VIVID_CORE_H_
9 #define _VIVID_CORE_H_
10
11 #include <linux/fb.h>
12 #include <linux/workqueue.h>
13 #include <media/cec.h>
14 #include <media/videobuf2-v4l2.h>
15 #include <media/v4l2-device.h>
16 #include <media/v4l2-dev.h>
17 #include <media/v4l2-ctrls.h>
18 #include <media/tpg/v4l2-tpg.h>
19 #include "vivid-rds-gen.h"
20 #include "vivid-vbi-gen.h"
21
22 #define dprintk(dev, level, fmt, arg...) \
23 v4l2_dbg(level, vivid_debug, &dev->v4l2_dev, fmt, ## arg)
24
25 /* The maximum number of inputs */
26 #define MAX_INPUTS 16
27 /* The maximum number of outputs */
28 #define MAX_OUTPUTS 16
29 /* The maximum number of video capture buffers */
30 #define MAX_VID_CAP_BUFFERS 64
31 /* The maximum up or down scaling factor is 4 */
32 #define MAX_ZOOM 4
33 /* The maximum image width/height are set to 4K DMT */
34 #define MAX_WIDTH 4096
35 #define MAX_HEIGHT 2160
36 /* The minimum image width/height */
37 #define MIN_WIDTH 16
38 #define MIN_HEIGHT MIN_WIDTH
39 /* Pixel Array control divider */
40 #define PIXEL_ARRAY_DIV MIN_WIDTH
41 /* The data_offset of plane 0 for the multiplanar formats */
42 #define PLANE0_DATA_OFFSET 128
43
44 /* The supported TV frequency range in MHz */
45 #define MIN_TV_FREQ (44U * 16U)
46 #define MAX_TV_FREQ (958U * 16U)
47
48 /* The number of samples returned in every SDR buffer */
49 #define SDR_CAP_SAMPLES_PER_BUF 0x4000
50
51 /* used by the threads to know when to resync internal counters */
52 #define JIFFIES_PER_DAY (3600U * 24U * HZ)
53 #define JIFFIES_RESYNC (JIFFIES_PER_DAY * (0xf0000000U / JIFFIES_PER_DAY))
54
55 /*
56 * Maximum number of HDMI inputs allowed by vivid, due to limitations
57 * of the Physical Address in the EDID and used by CEC we stop at 15
58 * inputs and outputs.
59 */
60 #define MAX_HDMI_INPUTS 15
61 #define MAX_HDMI_OUTPUTS 15
62
63 /* Maximum number of S-Video inputs allowed by vivid */
64 #define MAX_SVID_INPUTS 16
65
66 /* The maximum number of items in a menu control */
67 #define MAX_MENU_ITEMS BITS_PER_LONG_LONG
68
69 /* Number of fixed menu items in the 'Connected To' menu controls */
70 #define FIXED_MENU_ITEMS 2
71
72 /* The maximum number of vivid devices */
73 #define VIVID_MAX_DEVS CONFIG_VIDEO_VIVID_MAX_DEVS
74
75 extern const struct v4l2_rect vivid_min_rect;
76 extern const struct v4l2_rect vivid_max_rect;
77 extern unsigned vivid_debug;
78
79 /*
80 * NULL-terminated string array for the HDMI 'Connected To' menu controls
81 * with the list of possible HDMI outputs.
82 *
83 * The first two items are fixed ("TPG" and "None").
84 */
85 extern char *vivid_ctrl_hdmi_to_output_strings[1 + MAX_MENU_ITEMS];
86 /* Menu control skip mask of all HDMI outputs that are in use */
87 extern u64 hdmi_to_output_menu_skip_mask;
88 /*
89 * Bitmask of which vivid instances need to update any connected
90 * HDMI outputs.
91 */
92 extern u64 hdmi_input_update_outputs_mask;
93 /*
94 * Spinlock for access to hdmi_to_output_menu_skip_mask and
95 * hdmi_input_update_outputs_mask.
96 */
97 extern spinlock_t hdmi_output_skip_mask_lock;
98 /*
99 * Workqueue that updates the menu controls whenever the HDMI menu skip mask
100 * changes.
101 */
102 extern struct workqueue_struct *update_hdmi_ctrls_workqueue;
103
104 /*
105 * The HDMI menu control value (index in the menu list) maps to an HDMI
106 * output that is part of the given vivid_dev instance and has the given
107 * output index (as returned by VIDIOC_G_OUTPUT).
108 *
109 * NULL/0 if not available.
110 */
111 extern struct vivid_dev *vivid_ctrl_hdmi_to_output_instance[MAX_MENU_ITEMS];
112 extern unsigned int vivid_ctrl_hdmi_to_output_index[MAX_MENU_ITEMS];
113
114 /*
115 * NULL-terminated string array for the S-Video 'Connected To' menu controls
116 * with the list of possible S-Video outputs.
117 *
118 * The first two items are fixed ("TPG" and "None").
119 */
120 extern char *vivid_ctrl_svid_to_output_strings[1 + MAX_MENU_ITEMS];
121 /* Menu control skip mask of all S-Video outputs that are in use */
122 extern u64 svid_to_output_menu_skip_mask;
123 /* Spinlock for access to svid_to_output_menu_skip_mask */
124 extern spinlock_t svid_output_skip_mask_lock;
125 /*
126 * Workqueue that updates the menu controls whenever the S-Video menu skip mask
127 * changes.
128 */
129 extern struct workqueue_struct *update_svid_ctrls_workqueue;
130
131 /*
132 * The S-Video menu control value (index in the menu list) maps to an S-Video
133 * output that is part of the given vivid_dev instance and has the given
134 * output index (as returned by VIDIOC_G_OUTPUT).
135 *
136 * NULL/0 if not available.
137 */
138 extern struct vivid_dev *vivid_ctrl_svid_to_output_instance[MAX_MENU_ITEMS];
139 extern unsigned int vivid_ctrl_svid_to_output_index[MAX_MENU_ITEMS];
140
141 extern struct vivid_dev *vivid_devs[VIVID_MAX_DEVS];
142 extern unsigned int n_devs;
143
144 struct vivid_fmt {
145 u32 fourcc; /* v4l2 format id */
146 enum tgp_color_enc color_enc;
147 bool can_do_overlay;
148 u8 vdownsampling[TPG_MAX_PLANES];
149 u32 alpha_mask;
150 u8 planes;
151 u8 buffers;
152 u32 data_offset[TPG_MAX_PLANES];
153 u32 bit_depth[TPG_MAX_PLANES];
154 };
155
156 extern struct vivid_fmt vivid_formats[];
157
158 /* buffer for one video frame */
159 struct vivid_buffer {
160 /* common v4l buffer stuff -- must be first */
161 struct vb2_v4l2_buffer vb;
162 struct list_head list;
163 };
164
165 enum vivid_input {
166 WEBCAM,
167 TV,
168 SVID,
169 HDMI,
170 };
171
172 enum vivid_signal_mode {
173 CURRENT_DV_TIMINGS,
174 CURRENT_STD = CURRENT_DV_TIMINGS,
175 NO_SIGNAL,
176 NO_LOCK,
177 OUT_OF_RANGE,
178 SELECTED_DV_TIMINGS,
179 SELECTED_STD = SELECTED_DV_TIMINGS,
180 CYCLE_DV_TIMINGS,
181 CYCLE_STD = CYCLE_DV_TIMINGS,
182 CUSTOM_DV_TIMINGS,
183 };
184
185 enum vivid_colorspace {
186 VIVID_CS_170M,
187 VIVID_CS_709,
188 VIVID_CS_SRGB,
189 VIVID_CS_OPRGB,
190 VIVID_CS_2020,
191 VIVID_CS_DCI_P3,
192 VIVID_CS_240M,
193 VIVID_CS_SYS_M,
194 VIVID_CS_SYS_BG,
195 };
196
197 #define VIVID_INVALID_SIGNAL(mode) \
198 ((mode) == NO_SIGNAL || (mode) == NO_LOCK || (mode) == OUT_OF_RANGE)
199
200 struct vivid_cec_xfer {
201 struct cec_adapter *adap;
202 u8 msg[CEC_MAX_MSG_SIZE];
203 u32 len;
204 u32 sft;
205 };
206
207 struct vivid_dev {
208 u8 inst;
209 struct v4l2_device v4l2_dev;
210 #ifdef CONFIG_MEDIA_CONTROLLER
211 struct media_device mdev;
212 struct media_pad vid_cap_pad;
213 struct media_pad vid_out_pad;
214 struct media_pad vbi_cap_pad;
215 struct media_pad vbi_out_pad;
216 struct media_pad sdr_cap_pad;
217 struct media_pad meta_cap_pad;
218 struct media_pad meta_out_pad;
219 struct media_pad touch_cap_pad;
220 #endif
221 struct v4l2_ctrl_handler ctrl_hdl_user_gen;
222 struct v4l2_ctrl_handler ctrl_hdl_user_vid;
223 struct v4l2_ctrl_handler ctrl_hdl_user_aud;
224 struct v4l2_ctrl_handler ctrl_hdl_streaming;
225 struct v4l2_ctrl_handler ctrl_hdl_sdtv_cap;
226 struct v4l2_ctrl_handler ctrl_hdl_loop_cap;
227 struct v4l2_ctrl_handler ctrl_hdl_fb;
228 struct video_device vid_cap_dev;
229 struct v4l2_ctrl_handler ctrl_hdl_vid_cap;
230 struct video_device vid_out_dev;
231 struct v4l2_ctrl_handler ctrl_hdl_vid_out;
232 struct video_device vbi_cap_dev;
233 struct v4l2_ctrl_handler ctrl_hdl_vbi_cap;
234 struct video_device vbi_out_dev;
235 struct v4l2_ctrl_handler ctrl_hdl_vbi_out;
236 struct video_device radio_rx_dev;
237 struct v4l2_ctrl_handler ctrl_hdl_radio_rx;
238 struct video_device radio_tx_dev;
239 struct v4l2_ctrl_handler ctrl_hdl_radio_tx;
240 struct video_device sdr_cap_dev;
241 struct v4l2_ctrl_handler ctrl_hdl_sdr_cap;
242 struct video_device meta_cap_dev;
243 struct v4l2_ctrl_handler ctrl_hdl_meta_cap;
244 struct video_device meta_out_dev;
245 struct v4l2_ctrl_handler ctrl_hdl_meta_out;
246 struct video_device touch_cap_dev;
247 struct v4l2_ctrl_handler ctrl_hdl_touch_cap;
248
249 spinlock_t slock;
250 struct mutex mutex;
251 struct work_struct update_hdmi_ctrl_work;
252 struct work_struct update_svid_ctrl_work;
253
254 /* capabilities */
255 u32 vid_cap_caps;
256 u32 vid_out_caps;
257 u32 vbi_cap_caps;
258 u32 vbi_out_caps;
259 u32 sdr_cap_caps;
260 u32 radio_rx_caps;
261 u32 radio_tx_caps;
262 u32 meta_cap_caps;
263 u32 meta_out_caps;
264 u32 touch_cap_caps;
265
266 /* supported features */
267 bool multiplanar;
268 u8 num_inputs;
269 u8 num_hdmi_inputs;
270 u8 num_svid_inputs;
271 u8 input_type[MAX_INPUTS];
272 u8 input_name_counter[MAX_INPUTS];
273 u8 num_outputs;
274 u8 num_hdmi_outputs;
275 u8 output_type[MAX_OUTPUTS];
276 u8 output_name_counter[MAX_OUTPUTS];
277 bool has_audio_inputs;
278 bool has_audio_outputs;
279 bool has_vid_cap;
280 bool has_vid_out;
281 bool has_vbi_cap;
282 bool has_raw_vbi_cap;
283 bool has_sliced_vbi_cap;
284 bool has_vbi_out;
285 bool has_raw_vbi_out;
286 bool has_sliced_vbi_out;
287 bool has_radio_rx;
288 bool has_radio_tx;
289 bool has_sdr_cap;
290 bool has_fb;
291 bool has_meta_cap;
292 bool has_meta_out;
293 bool has_tv_tuner;
294 bool has_touch_cap;
295
296 /* Output index (0-MAX_OUTPUTS) to vivid instance of connected input */
297 struct vivid_dev *output_to_input_instance[MAX_OUTPUTS];
298 /* Output index (0-MAX_OUTPUTS) to input index (0-MAX_INPUTS) of connected input */
299 u8 output_to_input_index[MAX_OUTPUTS];
300 /* Output index (0-MAX_OUTPUTS) to HDMI or S-Video output index (0-MAX_HDMI/SVID_OUTPUTS) */
301 u8 output_to_iface_index[MAX_OUTPUTS];
302 /* ctrl_hdmi_to_output or ctrl_svid_to_output control value for each input */
303 s32 input_is_connected_to_output[MAX_INPUTS];
304 /* HDMI index (0-MAX_HDMI_OUTPUTS) to output index (0-MAX_OUTPUTS) */
305 u8 hdmi_index_to_output_index[MAX_HDMI_OUTPUTS];
306 /* HDMI index (0-MAX_HDMI_INPUTS) to input index (0-MAX_INPUTS) */
307 u8 hdmi_index_to_input_index[MAX_HDMI_INPUTS];
308 /* S-Video index (0-MAX_SVID_INPUTS) to input index (0-MAX_INPUTS) */
309 u8 svid_index_to_input_index[MAX_SVID_INPUTS];
310
311 /* controls */
312 struct v4l2_ctrl *brightness;
313 struct v4l2_ctrl *contrast;
314 struct v4l2_ctrl *saturation;
315 struct v4l2_ctrl *hue;
316 struct {
317 /* autogain/gain cluster */
318 struct v4l2_ctrl *autogain;
319 struct v4l2_ctrl *gain;
320 };
321 struct v4l2_ctrl *volume;
322 struct v4l2_ctrl *mute;
323 struct v4l2_ctrl *alpha;
324 struct v4l2_ctrl *button;
325 struct v4l2_ctrl *boolean;
326 struct v4l2_ctrl *int32;
327 struct v4l2_ctrl *int64;
328 struct v4l2_ctrl *menu;
329 struct v4l2_ctrl *string;
330 struct v4l2_ctrl *bitmask;
331 struct v4l2_ctrl *int_menu;
332 struct v4l2_ctrl *ro_int32;
333 struct v4l2_ctrl *pixel_array;
334 struct v4l2_ctrl *test_pattern;
335 struct v4l2_ctrl *colorspace;
336 struct v4l2_ctrl *rgb_range_cap;
337 struct v4l2_ctrl *real_rgb_range_cap;
338 struct {
339 /* std_signal_mode/standard cluster */
340 struct v4l2_ctrl *ctrl_std_signal_mode;
341 struct v4l2_ctrl *ctrl_standard;
342 };
343 struct {
344 /* dv_timings_signal_mode/timings cluster */
345 struct v4l2_ctrl *ctrl_dv_timings_signal_mode;
346 struct v4l2_ctrl *ctrl_dv_timings;
347 };
348 struct v4l2_ctrl *ctrl_has_crop_cap;
349 struct v4l2_ctrl *ctrl_has_compose_cap;
350 struct v4l2_ctrl *ctrl_has_scaler_cap;
351 struct v4l2_ctrl *ctrl_has_crop_out;
352 struct v4l2_ctrl *ctrl_has_compose_out;
353 struct v4l2_ctrl *ctrl_has_scaler_out;
354 struct v4l2_ctrl *ctrl_tx_mode;
355 struct v4l2_ctrl *ctrl_tx_rgb_range;
356 struct v4l2_ctrl *ctrl_tx_edid_present;
357 struct v4l2_ctrl *ctrl_tx_hotplug;
358 struct v4l2_ctrl *ctrl_tx_rxsense;
359
360 struct v4l2_ctrl *ctrl_rx_power_present;
361
362 struct v4l2_ctrl *radio_tx_rds_pi;
363 struct v4l2_ctrl *radio_tx_rds_pty;
364 struct v4l2_ctrl *radio_tx_rds_mono_stereo;
365 struct v4l2_ctrl *radio_tx_rds_art_head;
366 struct v4l2_ctrl *radio_tx_rds_compressed;
367 struct v4l2_ctrl *radio_tx_rds_dyn_pty;
368 struct v4l2_ctrl *radio_tx_rds_ta;
369 struct v4l2_ctrl *radio_tx_rds_tp;
370 struct v4l2_ctrl *radio_tx_rds_ms;
371 struct v4l2_ctrl *radio_tx_rds_psname;
372 struct v4l2_ctrl *radio_tx_rds_radiotext;
373
374 struct v4l2_ctrl *radio_rx_rds_pty;
375 struct v4l2_ctrl *radio_rx_rds_ta;
376 struct v4l2_ctrl *radio_rx_rds_tp;
377 struct v4l2_ctrl *radio_rx_rds_ms;
378 struct v4l2_ctrl *radio_rx_rds_psname;
379 struct v4l2_ctrl *radio_rx_rds_radiotext;
380
381 struct v4l2_ctrl *ctrl_hdmi_to_output[MAX_HDMI_INPUTS];
382 char ctrl_hdmi_to_output_names[MAX_HDMI_INPUTS][32];
383 struct v4l2_ctrl *ctrl_svid_to_output[MAX_SVID_INPUTS];
384 char ctrl_svid_to_output_names[MAX_SVID_INPUTS][32];
385
386 unsigned input_brightness[MAX_INPUTS];
387 unsigned osd_mode;
388 unsigned button_pressed;
389 bool sensor_hflip;
390 bool sensor_vflip;
391 bool hflip;
392 bool vflip;
393 bool vbi_cap_interlaced;
394 bool loop_video;
395 bool reduced_fps;
396
397 /* Framebuffer */
398 unsigned long video_pbase;
399 void *video_vbase;
400 u32 video_buffer_size;
401 int display_width;
402 int display_height;
403 int display_byte_stride;
404 int bits_per_pixel;
405 int bytes_per_pixel;
406 #ifdef CONFIG_VIDEO_VIVID_OSD
407 struct fb_info fb_info;
408 struct fb_var_screeninfo fb_defined;
409 struct fb_fix_screeninfo fb_fix;
410 #endif
411
412 /* Error injection */
413 bool disconnect_error;
414 bool queue_setup_error;
415 bool buf_prepare_error;
416 bool start_streaming_error;
417 bool dqbuf_error;
418 bool req_validate_error;
419 bool seq_wrap;
420 u64 time_wrap;
421 u64 time_wrap_offset;
422 unsigned perc_dropped_buffers;
423 enum vivid_signal_mode std_signal_mode[MAX_INPUTS];
424 unsigned int query_std_last[MAX_INPUTS];
425 v4l2_std_id query_std[MAX_INPUTS];
426 enum tpg_video_aspect std_aspect_ratio[MAX_INPUTS];
427
428 enum vivid_signal_mode dv_timings_signal_mode[MAX_INPUTS];
429 char **query_dv_timings_qmenu;
430 char *query_dv_timings_qmenu_strings;
431 unsigned query_dv_timings_size;
432 unsigned int query_dv_timings_last[MAX_INPUTS];
433 unsigned int query_dv_timings[MAX_INPUTS];
434 enum tpg_video_aspect dv_timings_aspect_ratio[MAX_INPUTS];
435
436 /* Input */
437 unsigned input;
438 v4l2_std_id std_cap[MAX_INPUTS];
439 struct v4l2_dv_timings dv_timings_cap[MAX_INPUTS];
440 int dv_timings_cap_sel[MAX_INPUTS];
441 u32 service_set_cap;
442 struct vivid_vbi_gen_data vbi_gen;
443 u8 *edid;
444 unsigned edid_blocks;
445 unsigned edid_max_blocks;
446 unsigned webcam_size_idx;
447 unsigned webcam_ival_idx;
448 unsigned tv_freq;
449 unsigned tv_audmode;
450 unsigned tv_field_cap;
451 unsigned tv_audio_input;
452
453 u32 power_present;
454
455 /* Output */
456 unsigned output;
457 v4l2_std_id std_out;
458 struct v4l2_dv_timings dv_timings_out;
459 u32 colorspace_out;
460 u32 ycbcr_enc_out;
461 u32 hsv_enc_out;
462 u32 quantization_out;
463 u32 xfer_func_out;
464 u32 service_set_out;
465 unsigned bytesperline_out[TPG_MAX_PLANES];
466 unsigned tv_field_out;
467 unsigned tv_audio_output;
468 bool vbi_out_have_wss;
469 u8 vbi_out_wss[2];
470 bool vbi_out_have_cc[2];
471 u8 vbi_out_cc[2][2];
472 bool dvi_d_out;
473 u8 *scaled_line;
474 u8 *blended_line;
475 unsigned cur_scaled_line;
476
477 /* Output Overlay */
478 void *fb_vbase_out;
479 bool overlay_out_enabled;
480 int overlay_out_top, overlay_out_left;
481 unsigned fbuf_out_flags;
482 u32 chromakey_out;
483 u8 global_alpha_out;
484
485 /* video capture */
486 struct tpg_data tpg;
487 unsigned ms_vid_cap;
488 bool must_blank[MAX_VID_CAP_BUFFERS];
489
490 const struct vivid_fmt *fmt_cap;
491 struct v4l2_fract timeperframe_vid_cap;
492 enum v4l2_field field_cap;
493 struct v4l2_rect src_rect;
494 struct v4l2_rect fmt_cap_rect;
495 struct v4l2_rect crop_cap;
496 struct v4l2_rect compose_cap;
497 struct v4l2_rect crop_bounds_cap;
498 struct vb2_queue vb_vid_cap_q;
499 struct list_head vid_cap_active;
500 struct vb2_queue vb_vbi_cap_q;
501 struct list_head vbi_cap_active;
502 struct vb2_queue vb_meta_cap_q;
503 struct list_head meta_cap_active;
504 struct vb2_queue vb_touch_cap_q;
505 struct list_head touch_cap_active;
506
507 /* thread for generating video capture stream */
508 struct task_struct *kthread_vid_cap;
509 unsigned long jiffies_vid_cap;
510 u64 cap_stream_start;
511 u64 cap_frame_period;
512 u64 cap_frame_eof_offset;
513 u32 cap_seq_offset;
514 u32 cap_seq_count;
515 bool cap_seq_resync;
516 u32 vid_cap_seq_start;
517 u32 vid_cap_seq_count;
518 bool vid_cap_streaming;
519 u32 vbi_cap_seq_start;
520 u32 vbi_cap_seq_count;
521 bool vbi_cap_streaming;
522 u32 meta_cap_seq_start;
523 u32 meta_cap_seq_count;
524 bool meta_cap_streaming;
525
526 /* Touch capture */
527 struct task_struct *kthread_touch_cap;
528 unsigned long jiffies_touch_cap;
529 u64 touch_cap_stream_start;
530 u32 touch_cap_seq_offset;
531 bool touch_cap_seq_resync;
532 u32 touch_cap_seq_start;
533 u32 touch_cap_seq_count;
534 u32 touch_cap_with_seq_wrap_count;
535 bool touch_cap_streaming;
536 struct v4l2_fract timeperframe_tch_cap;
537 struct v4l2_pix_format tch_format;
538 int tch_pat_random;
539
540 /* video output */
541 const struct vivid_fmt *fmt_out;
542 struct v4l2_fract timeperframe_vid_out;
543 enum v4l2_field field_out;
544 struct v4l2_rect sink_rect;
545 struct v4l2_rect fmt_out_rect;
546 struct v4l2_rect crop_out;
547 struct v4l2_rect compose_out;
548 struct v4l2_rect compose_bounds_out;
549 struct vb2_queue vb_vid_out_q;
550 struct list_head vid_out_active;
551 struct vb2_queue vb_vbi_out_q;
552 struct list_head vbi_out_active;
553 struct vb2_queue vb_meta_out_q;
554 struct list_head meta_out_active;
555
556 /* video loop precalculated rectangles */
557
558 /*
559 * Intersection between what the output side composes and the capture side
560 * crops. I.e., what actually needs to be copied from the output buffer to
561 * the capture buffer.
562 */
563 struct v4l2_rect loop_vid_copy;
564 /* The part of the output buffer that (after scaling) corresponds to loop_vid_copy. */
565 struct v4l2_rect loop_vid_out;
566 /* The part of the capture buffer that (after scaling) corresponds to loop_vid_copy. */
567 struct v4l2_rect loop_vid_cap;
568 /*
569 * The intersection of the framebuffer, the overlay output window and
570 * loop_vid_copy. I.e., the part of the framebuffer that actually should be
571 * blended with the compose_out rectangle. This uses the framebuffer origin.
572 */
573 struct v4l2_rect loop_fb_copy;
574 /* The same as loop_fb_copy but with compose_out origin. */
575 struct v4l2_rect loop_vid_overlay;
576 /*
577 * The part of the capture buffer that (after scaling) corresponds
578 * to loop_vid_overlay.
579 */
580 struct v4l2_rect loop_vid_overlay_cap;
581
582 /* thread for generating video output stream */
583 struct task_struct *kthread_vid_out;
584 unsigned long jiffies_vid_out;
585 u32 out_seq_offset;
586 u32 out_seq_count;
587 bool out_seq_resync;
588 u32 vid_out_seq_start;
589 u32 vid_out_seq_count;
590 bool vid_out_streaming;
591 u32 vbi_out_seq_start;
592 u32 vbi_out_seq_count;
593 bool vbi_out_streaming;
594 bool stream_sliced_vbi_out;
595 u32 meta_out_seq_start;
596 u32 meta_out_seq_count;
597 bool meta_out_streaming;
598
599 /* SDR capture */
600 struct vb2_queue vb_sdr_cap_q;
601 struct list_head sdr_cap_active;
602 u32 sdr_pixelformat; /* v4l2 format id */
603 unsigned sdr_buffersize;
604 unsigned sdr_adc_freq;
605 unsigned sdr_fm_freq;
606 unsigned sdr_fm_deviation;
607 int sdr_fixp_src_phase;
608 int sdr_fixp_mod_phase;
609
610 bool tstamp_src_is_soe;
611 bool has_crop_cap;
612 bool has_compose_cap;
613 bool has_scaler_cap;
614 bool has_crop_out;
615 bool has_compose_out;
616 bool has_scaler_out;
617
618 /* thread for generating SDR stream */
619 struct task_struct *kthread_sdr_cap;
620 unsigned long jiffies_sdr_cap;
621 u32 sdr_cap_seq_offset;
622 u32 sdr_cap_seq_start;
623 u32 sdr_cap_seq_count;
624 u32 sdr_cap_with_seq_wrap_count;
625 bool sdr_cap_seq_resync;
626
627 /* RDS generator */
628 struct vivid_rds_gen rds_gen;
629
630 /* Radio receiver */
631 unsigned radio_rx_freq;
632 unsigned radio_rx_audmode;
633 int radio_rx_sig_qual;
634 unsigned radio_rx_hw_seek_mode;
635 bool radio_rx_hw_seek_prog_lim;
636 bool radio_rx_rds_controls;
637 bool radio_rx_rds_enabled;
638 unsigned radio_rx_rds_use_alternates;
639 unsigned radio_rx_rds_last_block;
640 struct v4l2_fh *radio_rx_rds_owner;
641
642 /* Radio transmitter */
643 unsigned radio_tx_freq;
644 unsigned radio_tx_subchans;
645 bool radio_tx_rds_controls;
646 unsigned radio_tx_rds_last_block;
647 struct v4l2_fh *radio_tx_rds_owner;
648
649 /* Shared between radio receiver and transmitter */
650 bool radio_rds_loop;
651 ktime_t radio_rds_init_time;
652
653 /* CEC */
654 struct cec_adapter *cec_rx_adap;
655 struct cec_adapter *cec_tx_adap[MAX_HDMI_OUTPUTS];
656 struct task_struct *kthread_cec;
657 wait_queue_head_t kthread_waitq_cec;
658 struct vivid_cec_xfer xfers[MAX_OUTPUTS];
659 spinlock_t cec_xfers_slock; /* read and write cec messages */
660 u32 cec_sft; /* bus signal free time, in bit periods */
661 u8 last_initiator;
662
663 /* CEC OSD String */
664 char osd[14];
665 unsigned long osd_jiffies;
666
667 bool meta_pts;
668 bool meta_scr;
669 };
670
vivid_is_webcam(const struct vivid_dev * dev)671 static inline bool vivid_is_webcam(const struct vivid_dev *dev)
672 {
673 return dev->input_type[dev->input] == WEBCAM;
674 }
675
vivid_is_tv_cap(const struct vivid_dev * dev)676 static inline bool vivid_is_tv_cap(const struct vivid_dev *dev)
677 {
678 return dev->input_type[dev->input] == TV;
679 }
680
vivid_is_svid_cap(const struct vivid_dev * dev)681 static inline bool vivid_is_svid_cap(const struct vivid_dev *dev)
682 {
683 return dev->input_type[dev->input] == SVID;
684 }
685
vivid_is_hdmi_cap(const struct vivid_dev * dev)686 static inline bool vivid_is_hdmi_cap(const struct vivid_dev *dev)
687 {
688 return dev->input_type[dev->input] == HDMI;
689 }
690
vivid_is_sdtv_cap(const struct vivid_dev * dev)691 static inline bool vivid_is_sdtv_cap(const struct vivid_dev *dev)
692 {
693 return vivid_is_tv_cap(dev) || vivid_is_svid_cap(dev);
694 }
695
vivid_is_svid_out(const struct vivid_dev * dev)696 static inline bool vivid_is_svid_out(const struct vivid_dev *dev)
697 {
698 return dev->output_type[dev->output] == SVID;
699 }
700
vivid_is_hdmi_out(const struct vivid_dev * dev)701 static inline bool vivid_is_hdmi_out(const struct vivid_dev *dev)
702 {
703 return dev->output_type[dev->output] == HDMI;
704 }
705
706 #endif
707