Format: First byte must be 0x01. Remaining 32 bit words are spread out into chunks of 7 bytes each, with the first 4 bytes being the data word (little endian), and the next 3 bytes being the address where that data word is to be written (big endian). Repeat request for additional words, with offset adjusted accordingly.
Format: First byte must be 0x02 (status check) or 0x28 (read back block of 32 bit words). Next 6 bytes must be zero, followed by a single byte of MBOX_BASE+offset for portion to be read. Returned data is packed set of 32 bits words that were read.
/* This prototype is set up to be compatible with the cx2341x_mbox_func prototype in cx2341x.h, which should be in kernels 2.6.18 or later. We do this so that we can enable cx2341x.ko to write to our encoder (by handing it a pointer to this
function). For earlier kernels this doesn't really matter. */ staticint pvr2_encoder_cmd(void *ctxt,
u32 cmd, int arg_cnt_send, int arg_cnt_recv,
u32 *argp)
{ unsignedint poll_count; unsignedint try_count = 0; int retry_flag; int ret = 0; unsignedint idx; /* These sizes look to be limited by the FX2 firmware implementation */
u32 wrData[16];
u32 rdData[16]; struct pvr2_hdw *hdw = (struct pvr2_hdw *)ctxt;
/*
The encoder seems to speak entirely using blocks 32 bit words. In ivtv driver terms, this is a mailbox at MBOX_BASE which we populate with data and watch what the hardware does with it. The first word is a set of flags used to control the transaction, the second word is the command to execute, the third byte is zero (ivtv driver suggests that this is some kind of return value), and the fourth byte is a specified timeout (windows driver always uses 0x00060000 except for one case when it is zero). All successive words are the argument words for the command.
First, write out the entire set of words, with the first word being zero.
Next, write out just the first word again, but set it to IVTV_MBOX_DRIVER_DONE | IVTV_DRIVER_BUSY this time (which probably means "go").
Next, read back the return count words. Check the first word, which should have IVTV_MBOX_FIRMWARE_DONE set. If however that bit is not set, then the command isn't done so repeat the read until it is set.
Finally, write out just the first word again, but set it to 0x0 this time (which probably means "idle").
*/
if (arg_cnt_send > (ARRAY_SIZE(wrData) - 4)) {
pvr2_trace(
PVR2_TRACE_ERROR_LEGS, "Failed to write cx23416 command - too many input arguments (was given %u limit %lu)",
arg_cnt_send, (longunsigned) ARRAY_SIZE(wrData) - 4); return -EINVAL;
}
if (arg_cnt_recv > (ARRAY_SIZE(rdData) - 4)) {
pvr2_trace(
PVR2_TRACE_ERROR_LEGS, "Failed to write cx23416 command - too many return arguments (was given %u limit %lu)",
arg_cnt_recv, (longunsigned) ARRAY_SIZE(rdData) - 4); return -EINVAL;
}
LOCK_TAKE(hdw->ctl_lock); while (1) { if (!hdw->state_encoder_ok) {
ret = -EIO; break;
}
/* This implements some extra setup for the encoder that seems to be
specific to the PVR USB2 hardware. */ staticint pvr2_encoder_prep_config(struct pvr2_hdw *hdw)
{ int ret = 0; int encMisc3Arg = 0;
#if 0 /* This inexplicable bit happens in the Hauppauge windows driver (for both 24xxx and 29xxx devices). However I currently see no difference in behavior with or without this stuff. Leave this here as a note of its existence,
but don't use it. */
LOCK_TAKE(hdw->ctl_lock); do {
u32 dat[1];
dat[0] = 0x80000640;
pvr2_encoder_write_words(hdw,0x01fe,dat,1);
pvr2_encoder_write_words(hdw,0x023e,dat,1);
} while(0); LOCK_GIVE(hdw->ctl_lock); #endif
/* Mike Isely <isely@pobox.com> 26-Jan-2006 The windows driver sends the following list of ENC_MISC commands (for both 24xxx and 29xxx devices). Meanings are not entirely clear, however without the ENC_MISC(3,1) command then we risk random perpetual video corruption whenever the video input
breaks up for a moment (like when switching channels). */
#if 0 /* This ENC_MISC(5,0) command seems to hurt 29xxx sync performance on channel changes, but is not a problem on
24xxx devices. */
ret |= pvr2_encoder_vcmd(hdw, CX2341X_ENC_MISC,4, 5,0,0,0); #endif
/* This ENC_MISC(3,encMisc3Arg) command is critical - without it there will eventually be video corruption. Also, the saa7115 case is strange - the Windows driver is passing 1 regardless of device type but if we have 1 for saa7115
devices the video turns sluggish. */ if (hdw->hdw_desc->flag_has_cx25840) {
encMisc3Arg = 1;
} else {
encMisc3Arg = 0;
}
ret |= pvr2_encoder_vcmd(hdw, CX2341X_ENC_MISC,4, 3,
encMisc3Arg,0,0);
ret |= pvr2_encoder_vcmd(hdw, CX2341X_ENC_MISC,4, 8,0,0,0);
#if 0 /* This ENC_MISC(4,1) command is poisonous, so it is commented out. But I'm leaving it here anyway to document its existence in the Windows driver. The effect of this command is that apps displaying the stream become sluggish
with stuttering video. */
ret |= pvr2_encoder_vcmd(hdw, CX2341X_ENC_MISC,4, 4,1,0,0); #endif
ret |= pvr2_encoder_vcmd(hdw, CX2341X_ENC_MISC,4, 0,3,0,0);
ret |= pvr2_encoder_vcmd(hdw, CX2341X_ENC_MISC,4,15,0,0,0);
/* prevent the PTSs from slowly drifting away in the generated
MPEG stream */
ret |= pvr2_encoder_vcmd(hdw, CX2341X_ENC_MISC, 2, 4, 1);
return ret;
}
int pvr2_encoder_adjust(struct pvr2_hdw *hdw)
{ int ret;
ret = cx2341x_update(hdw,pvr2_encoder_cmd,
(hdw->enc_cur_valid ? &hdw->enc_cur_state : NULL),
&hdw->enc_ctl_state); if (ret) {
pvr2_trace(PVR2_TRACE_ERROR_LEGS, "Error from cx2341x module code=%d",ret);
} else {
hdw->enc_cur_state = hdw->enc_ctl_state;
hdw->enc_cur_valid = !0;
} return ret;
}
/* saa7115: 0xf0 */
val = 0xf0; if (hdw->hdw_desc->flag_has_cx25840) { /* ivtv cx25840: 0x140 */
val = 0x140;
}
if (!ret) ret = pvr2_encoder_vcmd(
hdw,CX2341X_ENC_SET_NUM_VSYNC_LINES, 2,
val, val);
/* setup firmware to notify us about some events (don't know why...) */ if (!ret) ret = pvr2_encoder_vcmd(
hdw,CX2341X_ENC_SET_EVENT_NOTIFICATION, 4,
0, 0, 0x10000000, 0xffffffff);
if (!ret) ret = pvr2_encoder_vcmd(
hdw,CX2341X_ENC_SET_VBI_LINE, 5,
0xffffffff,0,0,0,0);
if (ret) {
pvr2_trace(PVR2_TRACE_ERROR_LEGS, "Failed to configure cx23416"); return ret;
}
ret = pvr2_encoder_adjust(hdw); if (ret) return ret;
ret = pvr2_encoder_vcmd(
hdw, CX2341X_ENC_INITIALIZE_INPUT, 0);
if (ret) {
pvr2_trace(PVR2_TRACE_ERROR_LEGS, "Failed to initialize cx23416 video input"); return ret;
}
return 0;
}
int pvr2_encoder_start(struct pvr2_hdw *hdw)
{ int status;
/* unmask some interrupts */
pvr2_write_register(hdw, 0x0048, 0xbfffffff);
switch (hdw->active_stream_type) { case pvr2_config_vbi:
status = pvr2_encoder_vcmd(hdw,CX2341X_ENC_START_CAPTURE,2,
0x01,0x14); break; case pvr2_config_mpeg:
status = pvr2_encoder_vcmd(hdw,CX2341X_ENC_START_CAPTURE,2,
0,0x13); break; default: /* Unhandled cases for now */
status = pvr2_encoder_vcmd(hdw,CX2341X_ENC_START_CAPTURE,2,
0,0x13); break;
} return status;
}
int pvr2_encoder_stop(struct pvr2_hdw *hdw)
{ int status;
/* mask all interrupts */
pvr2_write_register(hdw, 0x0048, 0xffffffff);
switch (hdw->active_stream_type) { case pvr2_config_vbi:
status = pvr2_encoder_vcmd(hdw,CX2341X_ENC_STOP_CAPTURE,3,
0x01,0x01,0x14); break; case pvr2_config_mpeg:
status = pvr2_encoder_vcmd(hdw,CX2341X_ENC_STOP_CAPTURE,3,
0x01,0,0x13); break; default: /* Unhandled cases for now */
status = pvr2_encoder_vcmd(hdw,CX2341X_ENC_STOP_CAPTURE,3,
0x01,0,0x13); break;
}
return status;
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.2 Sekunden
(vorverarbeitet)
¤
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.