atv_demod: Add atv demod
authornengwen.chen <nengwen.chen@amlogic.com>
Sat, 14 Apr 2018 12:12:25 +0000 (20:12 +0800)
committerYixun Lan <yixun.lan@amlogic.com>
Tue, 17 Apr 2018 02:43:20 +0000 (18:43 -0800)
PD#163853: Add atv demod

Change-Id: I6e1fe3b50cccc2d6ee734ca77cf8593b95f47671
Signed-off-by: nengwen.chen <nengwen.chen@amlogic.com>
drivers/amlogic/atv_demod/atv_demod_ops.c
drivers/amlogic/atv_demod/atv_demod_v4l2.c
drivers/amlogic/atv_demod/atv_demod_v4l2.h

index b770520..13695e6 100644 (file)
@@ -374,15 +374,15 @@ static int atv_demod_set_config(struct dvb_frontend *fe, void *priv_cfg)
 
        mutex_lock(&atv_demod_list_mutex);
 
-       if (*state == AML_ATVDEMOD_INIT) {
+       if (*state == AML_ATVDEMOD_INIT && atvdemod_state != *state) {
                atv_demod_enter_mode();
                if (fe->ops.tuner_ops.init)
                        fe->ops.tuner_ops.init(fe);
-       } else if (*state == AML_ATVDEMOD_UNINIT) {
+       } else if (*state == AML_ATVDEMOD_UNINIT && atvdemod_state != *state) {
                atv_demod_leave_mode();
                if (fe->ops.tuner_ops.release)
                        fe->ops.tuner_ops.release(fe);
-       } else if (*state == AML_ATVDEMOD_RESUME) {
+       } else if (*state == AML_ATVDEMOD_RESUME && atvdemod_state != *state) {
                if (get_atvdemod_state() == ATVDEMOD_STATE_SLEEP)
                        atv_demod_enter_mode();
                if (fe->ops.tuner_ops.resume)
index 071f258..4419864 100644 (file)
@@ -240,11 +240,14 @@ static void v4l2_fe_try_analog_format(struct v4l2_frontend *v4l2_fe,
 #endif
 #else /* Now, force to NTSC_M, Ours demod only support M for NTSC.*/
                audio = V4L2_STD_NTSC_M;
+               std_bk |= V4L2_COLOR_STD_NTSC;
 #endif
        } else if (std_bk == V4L2_STD_SECAM) {
                audio = V4L2_STD_SECAM_L;
+               std_bk |= V4L2_COLOR_STD_SECAM;
        } else {
                /*V4L2_COLOR_STD_PAL*/
+               std_bk |= V4L2_COLOR_STD_PAL;
                amlatvdemod_set_std(AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_DK);
                audio = aml_audiomode_autodet(fe);
                audio = demod_fmt_2_v4l2_std(audio);
@@ -996,6 +999,28 @@ static int v4l2_frontend_set_mode(struct v4l2_frontend *v4l2_fe,
        return ret;
 }
 
+static int v4l2_frontend_read_status(struct v4l2_frontend *v4l2_fe,
+               enum v4l2_status *status)
+{
+       int ret = 0;
+       struct analog_demod_ops *analog_ops = NULL;
+       struct dvb_tuner_ops *tuner_ops = NULL;
+
+       analog_ops = &v4l2_fe->v4l2_ad->fe.ops.analog_ops;
+       tuner_ops = &v4l2_fe->v4l2_ad->fe.ops.tuner_ops;
+
+       if (!status)
+               return -1;
+#if 0
+       if (analog_ops->tuner_status)
+               analog_ops->tuner_status(&v4l2_fe->v4l2_ad->fe, status);
+       else if (tuner_ops->get_status)
+               tuner_ops->get_status(&v4l2_fe->v4l2_ad->fe, status);
+#endif
+
+       return ret;
+}
+
 static void v4l2_frontend_vdev_release(struct video_device *dev)
 {
        pr_err("%s.\n", __func__);
@@ -1026,7 +1051,7 @@ static unsigned int v4l2_frontend_poll(struct file *filp,
        if (fepriv->events.eventw != fepriv->events.eventr)
                return (POLLIN | POLLRDNORM | POLLPRI);
 
-       pr_err("%s.\n", __func__);
+       pr_info("%s.\n", __func__);
        return 0;
 }
 
@@ -1065,6 +1090,11 @@ static long v4l2_frontend_ioctl(struct file *filp, void *fh, bool valid_prio,
                ret = v4l2_frontend_set_mode(v4l2_fe, (unsigned long) arg);
                break;
 
+       case V4L2_READ_STATUS:
+               ret = v4l2_frontend_read_status(v4l2_fe,
+                               (enum v4l2_status *) arg);
+               break;
+
        default:
                break;
        }
index bf79df8..6e1acfb 100644 (file)
 #define V4L2_GET_FRONTEND    _IOR('V', 106, struct v4l2_analog_parameters)
 #define V4L2_GET_EVENT       _IOR('V', 107, struct v4l2_frontend_event)
 #define V4L2_SET_MODE        _IO('V', 108)
+#define V4L2_READ_STATUS     _IOR('V', 109, enum v4l2_status)
+
+/*COLOR MODULATION TYPE*/
+#define V4L2_COLOR_STD_PAL    ((v4l2_std_id) 0x04000000)
+#define V4L2_COLOR_STD_NTSC   ((v4l2_std_id) 0x08000000)
+#define V4L2_COLOR_STD_SECAM  ((v4l2_std_id) 0x10000000)
 
 struct v4l2_analog_parameters {
        unsigned int frequency;