u16 cx18_service2vbi(int type)
{ switch (type) { case V4L2_SLICED_TELETEXT_B: return CX18_SLICED_TYPE_TELETEXT_B; case V4L2_SLICED_CAPTION_525: return CX18_SLICED_TYPE_CAPTION_525; case V4L2_SLICED_WSS_625: return CX18_SLICED_TYPE_WSS_625; case V4L2_SLICED_VPS: return CX18_SLICED_TYPE_VPS; default: return 0;
}
}
/* Check if VBI services are allowed on the (field, line) for the video std */ staticint valid_service_line(int field, int line, int is_pal)
{ return (is_pal && line >= 6 &&
((field == 0 && line <= 23) || (field == 1 && line <= 22))) ||
(!is_pal && line >= 10 && line < 22);
}
/* * For a (field, line, std) and inbound potential set of services for that line, * return the first valid service of those passed in the incoming set for that * line in priority order: * CC, VPS, or WSS over TELETEXT for well known lines * TELETEXT, before VPS, before CC, before WSS, for other lines
*/ static u16 select_service_from_set(int field, int line, u16 set, int is_pal)
{
u16 valid_set = (is_pal ? V4L2_SLICED_VBI_625 : V4L2_SLICED_VBI_525); int i;
set = set & valid_set; if (set == 0 || !valid_service_line(field, line, is_pal)) return 0; if (!is_pal) { if (line == 21 && (set & V4L2_SLICED_CAPTION_525)) return V4L2_SLICED_CAPTION_525;
} else { if (line == 16 && field == 0 && (set & V4L2_SLICED_VPS)) return V4L2_SLICED_VPS; if (line == 23 && field == 0 && (set & V4L2_SLICED_WSS_625)) return V4L2_SLICED_WSS_625; if (line == 23) return 0;
} for (i = 0; i < 32; i++) { if (BIT(i) & set) return 1 << i;
} return 0;
}
/* * Expand the service_set of *fmt into valid service_lines for the std, * and clear the passed in fmt->service_set
*/ void cx18_expand_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal)
{
u16 set = fmt->service_set; int f, l;
fmt->service_set = 0; for (f = 0; f < 2; f++) { for (l = 0; l < 24; l++)
fmt->service_lines[f][l] = select_service_from_set(f, l, set, is_pal);
}
}
/* * Sanitize the service_lines in *fmt per the video std, and return 1 * if any service_line is left as valid after santization
*/ staticint check_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal)
{ int f, l;
u16 set = 0;
for (f = 0; f < 2; f++) { for (l = 0; l < 24; l++) {
fmt->service_lines[f][l] = select_service_from_set(f, l, fmt->service_lines[f][l], is_pal);
set |= fmt->service_lines[f][l];
}
} return set != 0;
}
/* Compute the service_set from the assumed valid service_lines of *fmt */
u16 cx18_get_service_set(struct v4l2_sliced_vbi_format *fmt)
{ int f, l;
u16 set = 0;
for (f = 0; f < 2; f++) { for (l = 0; l < 24; l++)
set |= fmt->service_lines[f][l];
} return set;
}
/* * Fetch the configured service_lines and total service_set from the * digitizer/slicer. Note, cx18_av_vbi() wipes the passed in * fmt->fmt.sliced under valid calling conditions
*/ if (v4l2_subdev_call(cx->sd_av, vbi, g_sliced_fmt, &fmt->fmt.sliced)) return -EINVAL;
/* If given a service set, expand it validly & clear passed in set */ if (vbifmt->service_set)
cx18_expand_service_set(vbifmt, cx->is_50hz); /* Sanitize the service_lines, and compute the new set if any valid */ if (check_service_set(vbifmt, cx->is_50hz))
vbifmt->service_set = cx18_get_service_set(vbifmt); return 0;
}
/* * Changing the Encoder's Raw VBI parameters won't have any effect * if any analog capture is ongoing
*/ if (!cx18_raw_vbi(cx) && atomic_read(&cx->ana_capturing) > 0) return -EBUSY;
/* * Set the digitizer registers for raw active VBI. * Note cx18_av_vbi_wipes out a lot of the passed in fmt under valid * calling conditions
*/
ret = v4l2_subdev_call(cx->sd_av, vbi, s_raw_fmt, &fmt->fmt.vbi); if (ret) return ret;
/* Store our new v4l2 (non-)sliced VBI state */
cx->vbi.sliced_in->service_set = 0;
cx->vbi.in.type = V4L2_BUF_TYPE_VBI_CAPTURE;
/* * Changing the Encoder's Raw VBI parameters won't have any effect * if any analog capture is ongoing
*/ if (cx18_raw_vbi(cx) && atomic_read(&cx->ana_capturing) > 0) return -EBUSY;
/* * Set the service_lines requested in the digitizer/slicer registers. * Note, cx18_av_vbi() wipes some "impossible" service lines in the * passed in fmt->fmt.sliced under valid calling conditions
*/
ret = v4l2_subdev_call(cx->sd_av, vbi, s_sliced_fmt, &fmt->fmt.sliced); if (ret) return ret; /* Store our current v4l2 sliced VBI settings */
cx->vbi.in.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE;
memcpy(cx->vbi.sliced_in, vbifmt, sizeof(*cx->vbi.sliced_in)); return 0;
}
if (test_bit(CX18_F_I_RADIO_USER, &cx->i_flags) ||
atomic_read(&cx->ana_capturing) > 0) { /* Switching standard would turn off the radio or mess with already running streams, prevent that by
returning EBUSY. */ return -EBUSY;
}
if (vt->type == V4L2_TUNER_RADIO)
strscpy(vt->name, "cx18 Radio Tuner", sizeof(vt->name)); else
strscpy(vt->name, "cx18 TV Tuner", sizeof(vt->name)); return 0;
}
staticint cx18_g_sliced_vbi_cap(struct file *file, void *fh, struct v4l2_sliced_vbi_cap *cap)
{ struct cx18 *cx = fh2id(fh)->cx; int set = cx->is_50hz ? V4L2_SLICED_VBI_625 : V4L2_SLICED_VBI_525; int f, l;
if (cap->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE) return -EINVAL;
cap->service_set = 0; for (f = 0; f < 2; f++) { for (l = 0; l < 24; l++) { if (valid_service_line(f, l, cx->is_50hz)) { /* * We can find all v4l2 supported vbi services * for the standard, on a valid line for the std
*/
cap->service_lines[f][l] = set;
cap->service_set |= set;
} else
cap->service_lines[f][l] = 0;
}
} for (f = 0; f < 3; f++)
cap->reserved[f] = 0; return 0;
}
/* * Assumption here is that a buf holds an integral number of * struct cx18_enc_idx_entry objects and is properly aligned. * This is enforced by the module options on IDX buffer sizes.
*/
remaining = buf->bytesused - buf->readpos;
consumed = 0;
e_idx = &idx->entry[idx->entries];
e_buf = (struct cx18_enc_idx_entry *) &buf->buf[buf->readpos];
while (remaining >= sizeof(struct cx18_enc_idx_entry) &&
idx->entries < V4L2_ENC_IDX_ENTRIES) {
/* Swallow any partial entries at the end, if there are any */ if (remaining > 0 && remaining < sizeof(struct cx18_enc_idx_entry))
consumed += remaining;
if (mdl->curr_buf == NULL)
mdl->curr_buf = list_first_entry(&mdl->buf_list, struct cx18_buffer, list);
if (list_entry_is_head(mdl->curr_buf, &mdl->buf_list, list)) { /* * For some reason we've exhausted the buffers, but the MDL * object still said some data was unread. * Fix that and bail out.
*/
mdl->readpos = mdl->bytesused; return 0;
}
/* Compute the best case number of entries we can buffer */
tmp = s->buffers -
s->bufs_per_mdl * CX18_ENC_STREAM_TYPE_IDX_FW_MDL_MIN; if (tmp <= 0)
tmp = 1;
tmp = tmp * s->buf_size / sizeof(struct cx18_enc_idx_entry);
/* Fill out the header of the return structure */
idx->entries = 0;
idx->entries_cap = tmp;
memset(idx->reserved, 0, sizeof(idx->reserved));
/* Pull IDX MDLs and buffers from q_full and populate the entries */ do {
mdl = cx18_dequeue(s, &s->q_full); if (mdl == NULL) /* No more IDX data right now */ break;
/* Extract the Index entry data from the MDL and buffers */
cx18_process_idx_data(s, mdl, idx); if (mdl->readpos < mdl->bytesused) { /* We finished with data remaining, push the MDL back */
cx18_push(s, mdl, &s->q_full); break;
}
/* We drained this MDL, schedule it to go to the firmware */
cx18_enqueue(s, mdl, &s->q_free);
} while (idx->entries < V4L2_ENC_IDX_ENTRIES);
/* Tell the work handler to send free IDX MDLs to the firmware */
cx18_stream_load_fw_queue(s); return 0;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.