[media] v4l: add RF tuner gain controls
authorAntti Palosaari <crope@iki.fi>
Sat, 25 Jan 2014 02:44:26 +0000 (23:44 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Wed, 5 Mar 2014 18:46:56 +0000 (15:46 -0300)
Modern silicon RF tuners used nowadays has many controllable gain
stages on signal path. Usually, but not always, there is at least
3 gain stages. Also on some cases there could be multiple gain
stages within the ones specified here. However, I think that having
these three controllable gain stages offers enough fine-tuning for
real use cases.

1) LNA gain. That is first gain just after antenna input.
2) Mixer gain. It is located quite middle of the signal path, where
RF signal is down-converted to IF/BB.
3) IF gain. That is last gain in order to adjust output signal level
to optimal level for receiving party (usually demodulator ADC).

Each gain stage could be set rather often both manual or automatic
(AGC) mode. Due to that add separate controls for controlling
operation mode.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
drivers/media/v4l2-core/v4l2-ctrls.c
include/uapi/linux/v4l2-controls.h

index e9e12c48c8743dd9bde83d3a82bc32e4ef09a5d5..1168f683fd48bf64ee70676524c2aa72c7b5754d 100644 (file)
@@ -859,6 +859,14 @@ const char *v4l2_ctrl_get_name(u32 id)
        case V4L2_CID_FM_RX_CLASS:              return "FM Radio Receiver Controls";
        case V4L2_CID_TUNE_DEEMPHASIS:          return "De-Emphasis";
        case V4L2_CID_RDS_RECEPTION:            return "RDS Reception";
+
+       case V4L2_CID_RF_TUNER_CLASS:           return "RF Tuner Controls";
+       case V4L2_CID_RF_TUNER_LNA_GAIN_AUTO:   return "LNA Gain, Auto";
+       case V4L2_CID_RF_TUNER_LNA_GAIN:        return "LNA Gain";
+       case V4L2_CID_RF_TUNER_MIXER_GAIN_AUTO: return "Mixer Gain, Auto";
+       case V4L2_CID_RF_TUNER_MIXER_GAIN:      return "Mixer Gain";
+       case V4L2_CID_RF_TUNER_IF_GAIN_AUTO:    return "IF Gain, Auto";
+       case V4L2_CID_RF_TUNER_IF_GAIN:         return "IF Gain";
        default:
                return NULL;
        }
@@ -908,6 +916,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
        case V4L2_CID_WIDE_DYNAMIC_RANGE:
        case V4L2_CID_IMAGE_STABILIZATION:
        case V4L2_CID_RDS_RECEPTION:
+       case V4L2_CID_RF_TUNER_LNA_GAIN_AUTO:
+       case V4L2_CID_RF_TUNER_MIXER_GAIN_AUTO:
+       case V4L2_CID_RF_TUNER_IF_GAIN_AUTO:
                *type = V4L2_CTRL_TYPE_BOOLEAN;
                *min = 0;
                *max = *step = 1;
@@ -997,6 +1008,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
        case V4L2_CID_IMAGE_PROC_CLASS:
        case V4L2_CID_DV_CLASS:
        case V4L2_CID_FM_RX_CLASS:
+       case V4L2_CID_RF_TUNER_CLASS:
                *type = V4L2_CTRL_TYPE_CTRL_CLASS;
                /* You can neither read not write these */
                *flags |= V4L2_CTRL_FLAG_READ_ONLY | V4L2_CTRL_FLAG_WRITE_ONLY;
@@ -1069,6 +1081,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
        case V4L2_CID_PILOT_TONE_FREQUENCY:
        case V4L2_CID_TUNE_POWER_LEVEL:
        case V4L2_CID_TUNE_ANTENNA_CAPACITOR:
+       case V4L2_CID_RF_TUNER_LNA_GAIN:
+       case V4L2_CID_RF_TUNER_MIXER_GAIN:
+       case V4L2_CID_RF_TUNER_IF_GAIN:
                *flags |= V4L2_CTRL_FLAG_SLIDER;
                break;
        case V4L2_CID_PAN_RELATIVE:
index cda6fa0262fc0971e1254e9b12f38e5ebf051968..e97101c1686f6aeb4c833309a10c019981481d36 100644 (file)
@@ -60,6 +60,7 @@
 #define V4L2_CTRL_CLASS_IMAGE_PROC     0x009f0000      /* Image processing controls */
 #define V4L2_CTRL_CLASS_DV             0x00a00000      /* Digital Video controls */
 #define V4L2_CTRL_CLASS_FM_RX          0x00a10000      /* FM Receiver controls */
+#define V4L2_CTRL_CLASS_RF_TUNER       0x00a20000      /* RF tuner controls */
 
 /* User-class control IDs */
 
@@ -897,4 +898,14 @@ enum v4l2_deemphasis {
 
 #define V4L2_CID_RDS_RECEPTION                 (V4L2_CID_FM_RX_CLASS_BASE + 2)
 
+#define V4L2_CID_RF_TUNER_CLASS_BASE           (V4L2_CTRL_CLASS_RF_TUNER | 0x900)
+#define V4L2_CID_RF_TUNER_CLASS                        (V4L2_CTRL_CLASS_RF_TUNER | 1)
+
+#define V4L2_CID_RF_TUNER_LNA_GAIN_AUTO                (V4L2_CID_RF_TUNER_CLASS_BASE + 1)
+#define V4L2_CID_RF_TUNER_LNA_GAIN             (V4L2_CID_RF_TUNER_CLASS_BASE + 2)
+#define V4L2_CID_RF_TUNER_MIXER_GAIN_AUTO      (V4L2_CID_RF_TUNER_CLASS_BASE + 3)
+#define V4L2_CID_RF_TUNER_MIXER_GAIN           (V4L2_CID_RF_TUNER_CLASS_BASE + 4)
+#define V4L2_CID_RF_TUNER_IF_GAIN_AUTO         (V4L2_CID_RF_TUNER_CLASS_BASE + 5)
+#define V4L2_CID_RF_TUNER_IF_GAIN              (V4L2_CID_RF_TUNER_CLASS_BASE + 6)
+
 #endif