staticint ths8200_write(struct v4l2_subdev *sd, u8 reg, u8 val)
{ struct i2c_client *client = v4l2_get_subdevdata(sd); int ret; int i;
for (i = 0; i < 3; i++) {
ret = i2c_smbus_write_byte_data(client, reg, val); if (ret == 0) return0;
}
v4l2_err(sd, "I2C Write Problem\n"); return ret;
}
/* To set specific bits in the register, a clear-mask is given (to be AND-ed), *andthenthevalue-mask(tobeOR-ed).
*/ staticinlinevoid
ths8200_write_and_or(struct v4l2_subdev *sd, u8 reg,
uint8_t clr_mask, uint8_t val_mask)
{
ths8200_write(sd, reg, (ths8200_read(sd, reg) & clr_mask) | val_mask);
}
/* Zero for progressive scan formats.*/ if (!bt->interlaced)
ths8200_write(sd, THS8200_DTG1_SPEC_C, 0x00);
/* Distance from leading edge of h sync to start of active video. *MSBin0x2b
*/
ths8200_write(sd, THS8200_DTG1_SPEC_D_LSB,
(bt->hbackporch + bt->hsync) & 0xff); /* Zero for SDTV-mode. MSB in 0x2b */
ths8200_write(sd, THS8200_DTG1_SPEC_E_LSB, 0x00); /* *MSBfordtg1_spec(d/e/h).Seecommentfor *correspondingLSBregisters.
*/
ths8200_write(sd, THS8200_DTG1_SPEC_DEH_MSB,
((bt->hbackporch + bt->hsync) & 0x100) >> 1);
/* h front porch */
ths8200_write(sd, THS8200_DTG1_SPEC_K_LSB, (bt->hfrontporch) & 0xff);
ths8200_write(sd, THS8200_DTG1_SPEC_K_MSB,
((bt->hfrontporch) & 0x700) >> 8);
/* Half the line length. Used to calculate SDTV line types. */
ths8200_write(sd, THS8200_DTG1_SPEC_G_LSB, (htotal(bt)/2) & 0xff);
ths8200_write(sd, THS8200_DTG1_SPEC_G_MSB,
((htotal(bt)/2) >> 8) & 0x0f);
/* Total pixels per line (ex. 720p: 1650) */
ths8200_write(sd, THS8200_DTG1_TOT_PIXELS_MSB, htotal(bt) >> 8);
ths8200_write(sd, THS8200_DTG1_TOT_PIXELS_LSB, htotal(bt) & 0xff);
/* Frame height and field height */ /* Field height should be programmed higher than frame_size for *progressivescanformats
*/
ths8200_write(sd, THS8200_DTG1_FRAME_FIELD_SZ_MSB,
((vtotal(bt) >> 4) & 0xf0) + 0x7);
ths8200_write(sd, THS8200_DTG1_FRAME_SZ_LSB, vtotal(bt) & 0xff);
/* Should be programmed higher than frame_size *forprogressiveformats
*/ if (!bt->interlaced)
ths8200_write(sd, THS8200_DTG1_FIELD_SZ_LSB, 0xff);
/* The pixel value h sync is asserted on */
ths8200_write_and_or(sd, THS8200_DTG2_HLENGTH_LSB_HDLY_MSB, 0xe0,
(htotal(bt) >> 8) & 0x1f);
ths8200_write(sd, THS8200_DTG2_HLENGTH_HDLY_LSB, htotal(bt));
/* v sync width transmitted (must add 1 to get correct output) */
ths8200_write(sd, THS8200_DTG2_VLENGTH1_LSB, (bt->vsync + 1) & 0xff);
ths8200_write_and_or(sd, THS8200_DTG2_VLENGTH1_MSB_VDLY1_MSB, 0x3f,
((bt->vsync + 1) >> 2) & 0xc0);
/* The pixel value v sync is asserted on (must add 1 to get correct output) */
ths8200_write_and_or(sd, THS8200_DTG2_VLENGTH1_MSB_VDLY1_MSB, 0xf8,
((vtotal(bt) + 1) >> 8) & 0x7);
ths8200_write(sd, THS8200_DTG2_VDLY1_LSB, vtotal(bt) + 1);
/* For progressive video vlength2 must be set to all 0 and vdly2 must *besettoall1.
*/
ths8200_write(sd, THS8200_DTG2_VLENGTH2_LSB, 0x00);
ths8200_write(sd, THS8200_DTG2_VLENGTH2_MSB_VDLY2_MSB, 0x07);
ths8200_write(sd, THS8200_DTG2_VDLY2_LSB, 0xff);
/* Internal delay factors to synchronize the sync pulses and the data */ /* Experimental values delays (hor 0, ver 0) */
ths8200_write(sd, THS8200_DTG2_HS_IN_DLY_MSB, 0);
ths8200_write(sd, THS8200_DTG2_HS_IN_DLY_LSB, 0);
ths8200_write(sd, THS8200_DTG2_VS_IN_DLY_MSB, 0);
ths8200_write(sd, THS8200_DTG2_VS_IN_DLY_LSB, 0);
/* Polarity of received and transmitted sync signals */ if (bt->polarities & V4L2_DV_HSYNC_POS_POL) {
polarity |= 0x01; /* HS_IN */
polarity |= 0x08; /* HS_OUT */
} if (bt->polarities & V4L2_DV_VSYNC_POS_POL) {
polarity |= 0x02; /* VS_IN */
polarity |= 0x10; /* VS_OUT */
}
/* RGB mode, no embedded timings */ /* Timing of video input bus is derived from HS, VS, and FID dedicated *inputs
*/
ths8200_write(sd, THS8200_DTG2_CNTL, 0x44 | polarity);
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.