piSmasher Configuration Libraries
piSmasher peripheral device configuration libraries

Functions

static int tda998x_mtx_set_coeffs (struct tda998x_dev *dev, struct tda998x_mtx_coeff *mtx)
 Set Matrix Coefficients. More...
 
static int tda998x_mtx_set_inoffset (struct tda998x_dev *dev, struct mtx_offset *offset)
 Set Matrix Input Offset. More...
 
static int tda998x_mtx_set_outoffset (struct tda998x_dev *dev, struct mtx_offset *offset)
 Set Matrix Output Offset. More...
 
static int tda998x_mtx_set_conv (struct tda998x_dev *dev, enum tda998x_vid_fmt vin_fmt, enum tda998x_vidin_mode vin_mode, enum tda998x_vid_fmt vout_fmt, enum tda998x_vidout_mode vout_mode, enum tda998x_vqr vqr)
 Set Matrix Conversion. More...
 
static int tda998x_mtx_set_mode (struct tda998x_dev *dev, enum mtx_cntrl_bp bp, enum mtx_cntrl_scale sc)
 Set Matrix Mode. More...
 

Detailed Description

Function Documentation

◆ tda998x_mtx_set_coeffs()

static int tda998x_mtx_set_coeffs ( struct tda998x_dev dev,
struct tda998x_mtx_coeff mtx 
)
static

#include <projects/lib/tda998x.c>

Set Matrix Coefficients.

Parameters
devTDA998x device structure pointer
mtxPointer to matrix coefficients structure
Returns
0 on success, non-zero error status otherwise
3690 {
3691  int i, ret;
3692  uint8_t buf[MTX_COEFF_LEN * 2];
3693 
3694  for (i = 0; i < MTX_COEFF_LEN; i++) {
3695  buf[i * 2] = (uint8_t) (((uint16_t) mtx->coeff[i] & 0x0700) >> 8);
3696  buf[(i * 2) + 1] = (uint8_t) ((uint16_t) mtx->coeff[i] & 0x00FF);
3697  }
3698 
3699  ret = tda998x_write(dev, MTX_P11_MSB, MTX_COEFF_LEN * 2, &buf[0]);
3700  if (ret < 0)
3701  return ret;
static int tda998x_write(struct tda998x_dev *dev, enum tda998x_hdmi_reg reg, uint8_t len, uint8_t *data)
Write Data.
Definition: tda998x.c:1247

◆ tda998x_mtx_set_conv()

static int tda998x_mtx_set_conv ( struct tda998x_dev dev,
enum tda998x_vid_fmt  vin_fmt,
enum tda998x_vidin_mode  vin_mode,
enum tda998x_vid_fmt  vout_fmt,
enum tda998x_vidout_mode  vout_mode,
enum tda998x_vqr  vqr 
)
static

#include <projects/lib/tda998x.c>

Set Matrix Conversion.

Parameters
devTDA998x device structure pointer
vin_fmtVideo input format
vout_fmtVideo output format
vout_modeVideo output mode
vqrVideo quantization range
Returns
0 on success, non-zero error status otherwise
3723 {
3724  int i, ret;
3725  enum tda998x_color_space cs_in;
3726  enum tda998x_color_space cs_out;
3727  int mtx_idx;
3728  uint8_t buf[31];
3729 
3730  /* Compute input color space */
3731  switch (vin_fmt) {
3744  /* HD modes */
3745  if (vin_mode == VINMODE_RGB444)
3746  cs_in = CS_RGB_LIMITED;
3747  else
3748  cs_in = CS_YUV_ITU_BT709; /* CCIR656, YUV444, YU422 */
3749 
3750  break;
3751 
3752  default:
3753  /* SD modes */
3754  if (vin_mode == VINMODE_RGB444)
3755  cs_in = CS_RGB_LIMITED;
3756  else
3757  cs_in = CS_YUV_ITU_BT601; /* CCIR656, YUV444, YU422 */
3758 
3759  break;
3760  }
3761 
3762  /* Compute output color space */
3763  switch (vout_fmt) {
3776  /* Catch the HD modes */
3777  if (vout_mode == VOUTMODE_RGB444) {
3778  cs_out = CS_RGB_LIMITED;
3779  } else {
3780  cs_out = CS_YUV_ITU_BT709; /* YUV444 or YUV422 */
3781  }
3782 
3783  break;
3784 
3785  default:
3786  /* SD modes */
3787  if (vout_mode == VOUTMODE_RGB444) {
3788  cs_out = CS_RGB_LIMITED;
3789  } else {
3790  cs_out = CS_YUV_ITU_BT601; /* YUV444 or YUV422 */
3791  }
3792 
3793  break;
3794  }
3795 
3796  if (cs_in == cs_out) {
3797  ret = write_reg_mask(dev,
3798  MTX_CNTRL,
3801  if (ret < 0)
3802  return ret;
3803  } else {
3804  ret = write_reg_mask(dev,
3805  MTX_CNTRL,
3807  0);
3808  if (ret < 0)
3809  return ret;
3810 
3811  for (i = 0; i < 31; i++)
3812  buf[i] = mtx_cfg_preset[mtx_idx][i];
3813 
3814  ret = write_reg_mask (dev,
3815  MTX_CNTRL,
3816  MTX_CNTRL_MTX_SC,
3817  buf[0]);
3818  if (ret < 0)
3819  return ret;
3820 
3821  ret = tda998x_write(dev, MTX_OI1_MSB, 30, &buf[1]);
3822  if (ret < 0)
3823  return ret;
3824  }
Definition: tda998x.h:113
Definition: tda998x.h:196
Definition: tda998x.h:89
Definition: tda998x.h:114
Definition: tda998x.h:107
Definition: tda998x.h:92
static int tda998x_write(struct tda998x_dev *dev, enum tda998x_hdmi_reg reg, uint8_t len, uint8_t *data)
Write Data.
Definition: tda998x.c:1247
Definition: tda998x.c:940
Definition: tda998x.c:939
Definition: tda998x.h:112
Definition: tda998x.h:77
tda998x_color_space
Definition: tda998x.c:936
static int write_reg_mask(struct tda998x_dev *dev, enum tda998x_hdmi_reg reg, uint8_t mask, uint8_t val)
Register Mask Write Write a value with mask bits to a register.
Definition: tda998x.c:1371
Definition: tda998x.h:78
Definition: tda998x.h:93
Definition: tda998x.h:105
Definition: tda998x.c:938
Definition: tda998x.h:129
Definition: tda998x.h:106
#define MTX_CNTRL_MTX_BP
Definition: tda998x.c:376
Definition: tda998x.h:104

◆ tda998x_mtx_set_inoffset()

static int tda998x_mtx_set_inoffset ( struct tda998x_dev dev,
struct mtx_offset offset 
)
static

#include <projects/lib/tda998x.c>

Set Matrix Input Offset.

Parameters
devTDA998x device structure pointer
offsetMatrix offset data structure pointer
Returns
0 on success, non-zero error status otherwise
3838 {
3839  int i, ret;
3840  uint8_t buf[MTX_OFFSET_LEN * 2];
3841 
3842  for (i = 0; i < MTX_OFFSET_LEN; i++) {
3843  buf[i * 2] = (uint8_t) (((uint16_t) offset->offset[i] & 0x0700) >> 8);
3844  buf[(i * 2) + 1] = (uint8_t) ((uint16_t) offset->offset[i] & 0x00FF);
3845  }
3846 
3847  ret = tda998x_write(dev,
3848  MTX_OI1_MSB,
3849  MTX_OFFSET_LEN * 2,
3850  &buf[0]);
3851  if (ret < 0)
3852  return ret;
#define MTX_OFFSET_LEN
Definition: tda998x.c:386
static int tda998x_write(struct tda998x_dev *dev, enum tda998x_hdmi_reg reg, uint8_t len, uint8_t *data)
Write Data.
Definition: tda998x.c:1247

◆ tda998x_mtx_set_mode()

static int tda998x_mtx_set_mode ( struct tda998x_dev dev,
enum mtx_cntrl_bp  bp,
enum mtx_cntrl_scale  sc 
)
static

#include <projects/lib/tda998x.c>

Set Matrix Mode.

Parameters
devTDA998x device structure pointer
bpMatrix bypass selection
scMatrix scaler selection
Returns
0 on success, non-zero error status otherwise
3900 {
3901  int ret;
3902 
3903  ret = write_reg_mask(dev,
3904  MTX_CNTRL,
3905  MTX_CNTRL_MTX_BP | MTX_CNTRL_MTX_SC,
3906  (uint8_t) bp | (uint8_t) sc);
3907  if (ret < 0)
3908  return ret;
static int write_reg_mask(struct tda998x_dev *dev, enum tda998x_hdmi_reg reg, uint8_t mask, uint8_t val)
Register Mask Write Write a value with mask bits to a register.
Definition: tda998x.c:1371
#define MTX_CNTRL_MTX_BP
Definition: tda998x.c:376

◆ tda998x_mtx_set_outoffset()

static int tda998x_mtx_set_outoffset ( struct tda998x_dev dev,
struct mtx_offset offset 
)
static

#include <projects/lib/tda998x.c>

Set Matrix Output Offset.

Parameters
devTDA998x device structure pointer
offsetMatrix offset data structure pointer
Returns
0 on success, non-zero error status otherwise
3866 {
3867  int i, ret;
3868  uint8_t buf[MTX_OFFSET_LEN * 2];
3869 
3870  if (dev == NULL)
3871  return ERR_NULL_PARAM;
3872 
3873  for (i = 0; i < MTX_OFFSET_LEN; i++) {
3874  buf[i * 2] = (uint8_t) (((uint16_t) offset->offset[i] & 0x0700) >> 8);
3875  buf[(i * 2) + 1] = (uint8_t) ((uint16_t) offset->offset[i] & 0x00FF);
3876  }
3877 
3878  ret = tda998x_write(dev,
3879  MTX_OO1_MSB,
3880  MTX_OFFSET_LEN * 2,
3881  &buf[0]);
3882  if (ret < 0)
3883  return ret;
#define MTX_OFFSET_LEN
Definition: tda998x.c:386
static int tda998x_write(struct tda998x_dev *dev, enum tda998x_hdmi_reg reg, uint8_t len, uint8_t *data)
Write Data.
Definition: tda998x.c:1247