Lines Matching +full:solid +full:- +full:state
1 // SPDX-License-Identifier: GPL-2.0+
12 #include <linux/v4l2-dv-timings.h>
14 #include <media/v4l2-ctrls.h>
15 #include <media/v4l2-device.h>
16 #include <media/v4l2-dv-timings.h>
17 #include <media/v4l2-ioctl.h>
21 /* -----------------------------------------------------------------------------
42 static int adv748x_afe_read_ro_map(struct adv748x_state *state, u8 reg)
46 /* Select SDP Read-Only Main Map */
47 ret = sdp_write(state, ADV748X_SDP_MAP_SEL,
52 return sdp_read(state, reg);
58 struct adv748x_state *state = adv748x_afe_to_state(afe);
62 info = adv748x_afe_read_ro_map(state, ADV748X_SDP_RO_10);
117 fmt->code = MEDIA_BUS_FMT_UYVY8_1X16;
118 fmt->colorspace = V4L2_COLORSPACE_SMPTE170M;
119 fmt->field = V4L2_FIELD_ALTERNATE;
121 fmt->width = 720;
122 fmt->height = afe->curr_norm & V4L2_STD_525_60 ? 480 : 576;
125 fmt->height /= 2;
147 return -EINVAL;
150 static void adv748x_afe_set_video_standard(struct adv748x_state *state,
153 sdp_clrset(state, ADV748X_SDP_VID_SEL, ADV748X_SDP_VID_SEL_MASK,
159 struct adv748x_state *state = adv748x_afe_to_state(afe);
161 return sdp_write(state, ADV748X_SDP_INSEL, input);
164 /* -----------------------------------------------------------------------------
172 *norm = afe->curr_norm;
180 struct adv748x_state *state = adv748x_afe_to_state(afe);
186 mutex_lock(&state->mutex);
188 adv748x_afe_set_video_standard(state, afe_std);
189 afe->curr_norm = std;
191 mutex_unlock(&state->mutex);
199 struct adv748x_state *state = adv748x_afe_to_state(afe);
203 mutex_lock(&state->mutex);
205 if (afe->streaming) {
206 ret = -EBUSY;
211 adv748x_afe_set_video_standard(state,
219 afe_std = adv748x_afe_std(afe->curr_norm);
223 /* Restore original state */
224 adv748x_afe_set_video_standard(state, afe_std);
227 mutex_unlock(&state->mutex);
242 struct adv748x_state *state = adv748x_afe_to_state(afe);
245 mutex_lock(&state->mutex);
249 mutex_unlock(&state->mutex);
257 struct adv748x_state *state = adv748x_afe_to_state(afe);
261 mutex_lock(&state->mutex);
264 ret = adv748x_afe_s_input(afe, afe->input);
269 ret = adv748x_tx_power(afe->tx, enable);
273 afe->streaming = enable;
277 adv_dbg(state, "Detected SDP signal\n");
279 adv_dbg(state, "Couldn't detect SDP video signal\n");
282 mutex_unlock(&state->mutex);
296 /* -----------------------------------------------------------------------------
304 tx = adv748x_get_remote_sd(&afe->pads[ADV748X_AFE_SOURCE]);
306 return -ENOLINK;
320 if (code->index != 0)
321 return -EINVAL;
323 code->code = MEDIA_BUS_FMT_UYVY8_1X16;
336 if (sdformat->pad != ADV748X_AFE_SOURCE)
337 return -EINVAL;
339 if (sdformat->which == V4L2_SUBDEV_FORMAT_TRY) {
341 sdformat->pad);
342 sdformat->format = *mbusformat;
344 adv748x_afe_fill_format(afe, &sdformat->format);
358 if (sdformat->pad != ADV748X_AFE_SOURCE)
359 return -EINVAL;
361 if (sdformat->which == V4L2_SUBDEV_FORMAT_ACTIVE)
364 mbusformat = v4l2_subdev_state_get_format(sd_state, sdformat->pad);
365 *mbusformat = sdformat->format;
376 /* -----------------------------------------------------------------------------
385 /* -----------------------------------------------------------------------------
391 "Solid Blue",
402 struct adv748x_state *state = adv748x_afe_to_state(afe);
406 ret = sdp_write(state, 0x0e, 0x00);
410 switch (ctrl->id) {
412 ret = sdp_write(state, ADV748X_SDP_BRI, ctrl->val);
416 ret = sdp_write(state, ADV748X_SDP_HUE, -ctrl->val);
419 ret = sdp_write(state, ADV748X_SDP_CON, ctrl->val);
422 ret = sdp_write(state, ADV748X_SDP_SD_SAT_U, ctrl->val);
425 ret = sdp_write(state, ADV748X_SDP_SD_SAT_V, ctrl->val);
428 enable = !!ctrl->val;
431 ret = sdp_clrset(state, ADV748X_SDP_DEF, ADV748X_SDP_DEF_VAL_EN,
435 ret = sdp_clrset(state, ADV748X_SDP_FRP, ADV748X_SDP_FRP_MASK,
436 enable ? ctrl->val - 1 : 0);
439 return -EINVAL;
451 struct adv748x_state *state = adv748x_afe_to_state(afe);
453 v4l2_ctrl_handler_init(&afe->ctrl_hdl, 5);
456 afe->ctrl_hdl.lock = &state->mutex;
458 v4l2_ctrl_new_std(&afe->ctrl_hdl, &adv748x_afe_ctrl_ops,
461 v4l2_ctrl_new_std(&afe->ctrl_hdl, &adv748x_afe_ctrl_ops,
464 v4l2_ctrl_new_std(&afe->ctrl_hdl, &adv748x_afe_ctrl_ops,
467 v4l2_ctrl_new_std(&afe->ctrl_hdl, &adv748x_afe_ctrl_ops,
471 v4l2_ctrl_new_std_menu_items(&afe->ctrl_hdl, &adv748x_afe_ctrl_ops,
473 ARRAY_SIZE(afe_ctrl_frp_menu) - 1,
476 afe->sd.ctrl_handler = &afe->ctrl_hdl;
477 if (afe->ctrl_hdl.error) {
478 v4l2_ctrl_handler_free(&afe->ctrl_hdl);
479 return afe->ctrl_hdl.error;
482 return v4l2_ctrl_handler_setup(&afe->ctrl_hdl);
487 struct adv748x_state *state = adv748x_afe_to_state(afe);
491 afe->input = 0;
492 afe->streaming = false;
493 afe->curr_norm = V4L2_STD_NTSC_M;
495 adv748x_subdev_init(&afe->sd, state, &adv748x_afe_ops,
500 /* Inputs and ports are 1-indexed to match the data sheet */
501 if (state->endpoints[i]) {
502 afe->input = i;
507 adv748x_afe_s_input(afe, afe->input);
509 adv_dbg(state, "AFE Default input set to %d\n", afe->input);
511 /* Entity pads and sinks are 0-indexed to match the pads */
513 afe->pads[i].flags = MEDIA_PAD_FL_SINK;
515 afe->pads[ADV748X_AFE_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
517 ret = media_entity_pads_init(&afe->sd.entity, ADV748X_AFE_NR_PADS,
518 afe->pads);
529 media_entity_cleanup(&afe->sd.entity);
536 v4l2_device_unregister_subdev(&afe->sd);
537 media_entity_cleanup(&afe->sd.entity);
538 v4l2_ctrl_handler_free(&afe->ctrl_hdl);