~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/media/video/pvrusb2/pvrusb2-hdw.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
499
499
        return 0;
500
500
}
501
501
 
502
 
static int ctrl_cropw_max_get(struct pvr2_ctrl *cptr, int *val)
 
502
static int ctrl_cropw_max_get(struct pvr2_ctrl *cptr, int *width)
503
503
{
504
504
        struct v4l2_cropcap *cap = &cptr->hdw->cropcap_info;
505
 
        int stat = pvr2_hdw_check_cropcap(cptr->hdw);
 
505
        int stat, bleftend, cleft;
 
506
 
 
507
        stat = pvr2_hdw_check_cropcap(cptr->hdw);
506
508
        if (stat != 0) {
507
509
                return stat;
508
510
        }
509
 
        *val = 0;
510
 
        if (cap->bounds.width > cptr->hdw->cropl_val) {
511
 
                *val = cap->bounds.width - cptr->hdw->cropl_val;
512
 
        }
 
511
        bleftend = cap->bounds.left+cap->bounds.width;
 
512
        cleft = cptr->hdw->cropl_val;
 
513
 
 
514
        *width = cleft < bleftend ? bleftend-cleft : 0;
513
515
        return 0;
514
516
}
515
517
 
516
 
static int ctrl_croph_max_get(struct pvr2_ctrl *cptr, int *val)
 
518
static int ctrl_croph_max_get(struct pvr2_ctrl *cptr, int *height)
517
519
{
518
520
        struct v4l2_cropcap *cap = &cptr->hdw->cropcap_info;
519
 
        int stat = pvr2_hdw_check_cropcap(cptr->hdw);
 
521
        int stat, btopend, ctop;
 
522
 
 
523
        stat = pvr2_hdw_check_cropcap(cptr->hdw);
520
524
        if (stat != 0) {
521
525
                return stat;
522
526
        }
523
 
        *val = 0;
524
 
        if (cap->bounds.height > cptr->hdw->cropt_val) {
525
 
                *val = cap->bounds.height - cptr->hdw->cropt_val;
526
 
        }
 
527
        btopend = cap->bounds.top+cap->bounds.height;
 
528
        ctop = cptr->hdw->cropt_val;
 
529
 
 
530
        *height = ctop < btopend ? btopend-ctop : 0;
527
531
        return 0;
528
532
}
529
533
 
1114
1118
                .internal_id = PVR2_CID_CROPW,
1115
1119
                .default_value = 720,
1116
1120
                DEFREF(cropw),
 
1121
                DEFINT(0, 864),
1117
1122
                .get_max_value = ctrl_cropw_max_get,
1118
1123
                .get_def_value = ctrl_get_cropcapdw,
1119
1124
        }, {
1122
1127
                .internal_id = PVR2_CID_CROPH,
1123
1128
                .default_value = 480,
1124
1129
                DEFREF(croph),
 
1130
                DEFINT(0, 576),
1125
1131
                .get_max_value = ctrl_croph_max_get,
1126
1132
                .get_def_value = ctrl_get_cropcapdh,
1127
1133
        }, {
2027
2033
                   hdw->decoder_client_id);
2028
2034
        memset(&fmt, 0, sizeof(fmt));
2029
2035
        fmt.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE;
 
2036
        fmt.fmt.sliced.service_lines[0][21] = V4L2_SLICED_CAPTION_525;
 
2037
        fmt.fmt.sliced.service_lines[1][21] = V4L2_SLICED_CAPTION_525;
2030
2038
        v4l2_device_call_all(&hdw->v4l2_dev, hdw->decoder_client_id,
2031
2039
                             vbi, s_sliced_fmt, &fmt.fmt.sliced);
2032
2040
}
2842
2850
                        PVR2_TRACE_ERROR_LEGS,
2843
2851
                        "WARNING: Failed to identify any viable standards");
2844
2852
        }
 
2853
 
 
2854
        /* Set up the dynamic control for this standard */
2845
2855
        hdw->std_enum_names = kmalloc(sizeof(char *)*(std_cnt+1),GFP_KERNEL);
2846
 
        hdw->std_enum_names[0] = "none";
2847
 
        for (idx = 0; idx < std_cnt; idx++) {
2848
 
                hdw->std_enum_names[idx+1] =
2849
 
                        newstd[idx].name;
 
2856
        if (hdw->std_enum_names) {
 
2857
                hdw->std_enum_names[0] = "none";
 
2858
                for (idx = 0; idx < std_cnt; idx++)
 
2859
                        hdw->std_enum_names[idx+1] = newstd[idx].name;
 
2860
                hdw->std_info_enum.def.type_enum.value_names =
 
2861
                                                hdw->std_enum_names;
 
2862
                hdw->std_info_enum.def.type_enum.count = std_cnt+1;
 
2863
        } else {
 
2864
                pvr2_trace(
 
2865
                        PVR2_TRACE_ERROR_LEGS,
 
2866
                        "WARNING: Failed to alloc memory for names");
 
2867
                hdw->std_info_enum.def.type_enum.value_names = NULL;
 
2868
                hdw->std_info_enum.def.type_enum.count = 0;
2850
2869
        }
2851
 
        // Set up the dynamic control for this standard
2852
 
        hdw->std_info_enum.def.type_enum.value_names = hdw->std_enum_names;
2853
 
        hdw->std_info_enum.def.type_enum.count = std_cnt+1;
2854
2870
        hdw->std_defs = newstd;
2855
2871
        hdw->std_enum_cnt = std_cnt+1;
2856
2872
        hdw->std_enum_cur = 0;
3030
3046
        if (hdw->input_dirty || hdw->audiomode_dirty || hdw->force_dirty) {
3031
3047
                struct v4l2_tuner vt;
3032
3048
                memset(&vt, 0, sizeof(vt));
 
3049
                vt.type = (hdw->input_val == PVR2_CVAL_INPUT_RADIO) ?
 
3050
                        V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
3033
3051
                vt.audmode = hdw->audiomode_val;
3034
3052
                v4l2_device_call_all(&hdw->v4l2_dev, 0, tuner, s_tuner, &vt);
3035
3053
        }
3165
3183
        struct pvr2_ctrl *cptr;
3166
3184
        int disruptive_change;
3167
3185
 
 
3186
        if (hdw->input_dirty && hdw->state_pathway_ok &&
 
3187
            (((hdw->input_val == PVR2_CVAL_INPUT_DTV) ?
 
3188
              PVR2_PATHWAY_DIGITAL : PVR2_PATHWAY_ANALOG) !=
 
3189
             hdw->pathway_state)) {
 
3190
                /* Change of mode being asked for... */
 
3191
                hdw->state_pathway_ok = 0;
 
3192
                trace_stbit("state_pathway_ok", hdw->state_pathway_ok);
 
3193
        }
 
3194
        if (!hdw->state_pathway_ok) {
 
3195
                /* Can't commit anything until pathway is ok. */
 
3196
                return 0;
 
3197
        }
 
3198
 
3168
3199
        /* Handle some required side effects when the video standard is
3169
3200
           changed.... */
3170
3201
        if (hdw->std_dirty) {
3199
3230
                }
3200
3231
        }
3201
3232
 
3202
 
        if (hdw->input_dirty && hdw->state_pathway_ok &&
3203
 
            (((hdw->input_val == PVR2_CVAL_INPUT_DTV) ?
3204
 
              PVR2_PATHWAY_DIGITAL : PVR2_PATHWAY_ANALOG) !=
3205
 
             hdw->pathway_state)) {
3206
 
                /* Change of mode being asked for... */
3207
 
                hdw->state_pathway_ok = 0;
3208
 
                trace_stbit("state_pathway_ok",hdw->state_pathway_ok);
3209
 
        }
3210
 
        if (!hdw->state_pathway_ok) {
3211
 
                /* Can't commit anything until pathway is ok. */
3212
 
                return 0;
3213
 
        }
3214
3233
        /* The broadcast decoder can only scale down, so if
3215
3234
         * res_*_dirty && crop window < output format ==> enlarge crop.
3216
3235
         *
5154
5173
{
5155
5174
        struct v4l2_tuner *vtp = &hdw->tuner_signal_info;
5156
5175
        memset(vtp, 0, sizeof(*vtp));
 
5176
        vtp->type = (hdw->input_val == PVR2_CVAL_INPUT_RADIO) ?
 
5177
                V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
5157
5178
        hdw->tuner_signal_stale = 0;
5158
5179
        /* Note: There apparently is no replacement for VIDIOC_CROPCAP
5159
5180
           using v4l2-subdev - therefore we can't support that AT ALL right
5160
5181
           now.  (Of course, no sub-drivers seem to implement it either.
5161
5182
           But now it's a a chicken and egg problem...) */
5162
 
        v4l2_device_call_all(&hdw->v4l2_dev, 0, tuner, g_tuner,
5163
 
                             &hdw->tuner_signal_info);
 
5183
        v4l2_device_call_all(&hdw->v4l2_dev, 0, tuner, g_tuner, vtp);
5164
5184
        pvr2_trace(PVR2_TRACE_CHIPS, "subdev status poll"
5165
5185
                   " type=%u strength=%u audio=0x%x cap=0x%x"
5166
5186
                   " low=%u hi=%u",