753
static int ivtv_g_priority(struct file *file, void *fh, enum v4l2_priority *p)
755
struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
757
*p = v4l2_prio_max(&itv->prio);
762
static int ivtv_s_priority(struct file *file, void *fh, enum v4l2_priority prio)
764
struct ivtv_open_id *id = fh;
765
struct ivtv *itv = id->itv;
767
return v4l2_prio_change(&itv->prio, &id->prio, prio);
770
753
static int ivtv_querycap(struct file *file, void *fh, struct v4l2_capability *vcap)
772
struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
755
struct ivtv *itv = fh2id(fh)->itv;
774
757
strlcpy(vcap->driver, IVTV_DRIVER_NAME, sizeof(vcap->driver));
775
758
strlcpy(vcap->card, itv->card_name, sizeof(vcap->card));
1083
1066
static int ivtv_g_std(struct file *file, void *fh, v4l2_std_id *std)
1085
struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
1068
struct ivtv *itv = fh2id(fh)->itv;
1087
1070
*std = itv->std;
1091
int ivtv_s_std(struct file *file, void *fh, v4l2_std_id *std)
1074
void ivtv_s_std_enc(struct ivtv *itv, v4l2_std_id *std)
1094
struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
1095
struct yuv_playback_info *yi = &itv->yuv_info;
1098
if ((*std & V4L2_STD_ALL) == 0)
1101
if (*std == itv->std)
1104
if (test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags) ||
1105
atomic_read(&itv->capturing) > 0 ||
1106
atomic_read(&itv->decoding) > 0) {
1107
/* Switching standard would turn off the radio or mess
1108
with already running streams, prevent that by
1113
1076
itv->std = *std;
1114
1077
itv->is_60hz = (*std & V4L2_STD_525_60) ? 1 : 0;
1115
1078
itv->is_50hz = !itv->is_60hz;
1123
1086
if (itv->hw_flags & IVTV_HW_CX25840)
1124
1087
itv->vbi.sliced_decoder_line_size = itv->is_60hz ? 272 : 284;
1126
IVTV_DEBUG_INFO("Switching standard to %llx.\n", (unsigned long long)itv->std);
1129
1090
ivtv_call_all(itv, core, s_std, itv->std);
1131
if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) {
1132
/* set display standard */
1133
itv->std_out = *std;
1134
itv->is_out_60hz = itv->is_60hz;
1135
itv->is_out_50hz = itv->is_50hz;
1136
ivtv_call_all(itv, video, s_std_output, itv->std_out);
1139
* The next firmware call is time sensitive. Time it to
1140
* avoid risk of a hard lock, by trying to ensure the call
1141
* happens within the first 100 lines of the top field.
1142
* Make 4 attempts to sync to the decoder before giving up.
1144
for (f = 0; f < 4; f++) {
1145
prepare_to_wait(&itv->vsync_waitq, &wait,
1146
TASK_UNINTERRUPTIBLE);
1147
if ((read_reg(IVTV_REG_DEC_LINE_FIELD) >> 16) < 100)
1149
schedule_timeout(msecs_to_jiffies(25));
1151
finish_wait(&itv->vsync_waitq, &wait);
1154
IVTV_WARN("Mode change failed to sync to decoder\n");
1156
ivtv_vapi(itv, CX2341X_DEC_SET_STANDARD, 1, itv->is_out_50hz);
1157
itv->main_rect.left = itv->main_rect.top = 0;
1158
itv->main_rect.width = 720;
1159
itv->main_rect.height = itv->cxhdl.height;
1160
ivtv_vapi(itv, CX2341X_OSD_SET_FRAMEBUFFER_WINDOW, 4,
1161
720, itv->main_rect.height, 0, 0);
1162
yi->main_rect = itv->main_rect;
1163
if (!itv->osd_info) {
1164
yi->osd_full_w = 720;
1165
yi->osd_full_h = itv->is_out_50hz ? 576 : 480;
1093
void ivtv_s_std_dec(struct ivtv *itv, v4l2_std_id *std)
1095
struct yuv_playback_info *yi = &itv->yuv_info;
1099
/* set display standard */
1100
itv->std_out = *std;
1101
itv->is_out_60hz = (*std & V4L2_STD_525_60) ? 1 : 0;
1102
itv->is_out_50hz = !itv->is_out_60hz;
1103
ivtv_call_all(itv, video, s_std_output, itv->std_out);
1106
* The next firmware call is time sensitive. Time it to
1107
* avoid risk of a hard lock, by trying to ensure the call
1108
* happens within the first 100 lines of the top field.
1109
* Make 4 attempts to sync to the decoder before giving up.
1111
for (f = 0; f < 4; f++) {
1112
prepare_to_wait(&itv->vsync_waitq, &wait,
1113
TASK_UNINTERRUPTIBLE);
1114
if ((read_reg(IVTV_REG_DEC_LINE_FIELD) >> 16) < 100)
1116
schedule_timeout(msecs_to_jiffies(25));
1118
finish_wait(&itv->vsync_waitq, &wait);
1121
IVTV_WARN("Mode change failed to sync to decoder\n");
1123
ivtv_vapi(itv, CX2341X_DEC_SET_STANDARD, 1, itv->is_out_50hz);
1124
itv->main_rect.left = 0;
1125
itv->main_rect.top = 0;
1126
itv->main_rect.width = 720;
1127
itv->main_rect.height = itv->is_out_50hz ? 576 : 480;
1128
ivtv_vapi(itv, CX2341X_OSD_SET_FRAMEBUFFER_WINDOW, 4,
1129
720, itv->main_rect.height, 0, 0);
1130
yi->main_rect = itv->main_rect;
1131
if (!itv->osd_info) {
1132
yi->osd_full_w = 720;
1133
yi->osd_full_h = itv->is_out_50hz ? 576 : 480;
1137
int ivtv_s_std(struct file *file, void *fh, v4l2_std_id *std)
1139
struct ivtv *itv = fh2id(fh)->itv;
1141
if ((*std & V4L2_STD_ALL) == 0)
1144
if (*std == itv->std)
1147
if (test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags) ||
1148
atomic_read(&itv->capturing) > 0 ||
1149
atomic_read(&itv->decoding) > 0) {
1150
/* Switching standard would mess with already running
1151
streams, prevent that by returning EBUSY. */
1155
IVTV_DEBUG_INFO("Switching standard to %llx.\n",
1156
(unsigned long long)itv->std);
1158
ivtv_s_std_enc(itv, std);
1159
if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)
1160
ivtv_s_std_dec(itv, std);
1171
1165
static int ivtv_s_tuner(struct file *file, void *fh, struct v4l2_tuner *vt)
1173
struct ivtv_open_id *id = fh;
1167
struct ivtv_open_id *id = fh2id(fh);
1174
1168
struct ivtv *itv = id->itv;
1176
1170
if (vt->index != 0)
1184
1178
static int ivtv_g_tuner(struct file *file, void *fh, struct v4l2_tuner *vt)
1186
struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
1180
struct ivtv *itv = fh2id(fh)->itv;
1188
1182
if (vt->index != 0)
1189
1183
return -EINVAL;
1191
1185
ivtv_call_all(itv, tuner, g_tuner, vt);
1193
if (test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags)) {
1187
if (vt->type == V4L2_TUNER_RADIO)
1194
1188
strlcpy(vt->name, "ivtv Radio Tuner", sizeof(vt->name));
1195
vt->type = V4L2_TUNER_RADIO;
1197
1190
strlcpy(vt->name, "ivtv TV Tuner", sizeof(vt->name));
1198
vt->type = V4L2_TUNER_ANALOG_TV;
1204
1194
static int ivtv_g_sliced_vbi_cap(struct file *file, void *fh, struct v4l2_sliced_vbi_cap *cap)
1206
struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
1196
struct ivtv *itv = fh2id(fh)->itv;
1207
1197
int set = itv->is_50hz ? V4L2_SLICED_VBI_625 : V4L2_SLICED_VBI_525;