adv7533.c
Go to the documentation of this file.
1 
20 /* Includes ------------------------------------------------------------------*/
21 #include "adv7533.h"
22 
37 /* Private types -------------------------------------------------------------*/
38 /* Private variables ---------------------------------------------------------*/
39 /* Private constants ---------------------------------------------------------*/
48 /* Private macros ------------------------------------------------------------*/
49 /* Private functions ---------------------------------------------------------*/
54 /* Audio codec driver structure initialization */
56 {
66  ADV7533_SetVolume, /* Not supported, added for compatibility */
67  ADV7533_GetVolume, /* Not supported, added for compatibility */
69  ADV7533_SetOutputMode, /* Not supported, added for compatibility */
70  ADV7533_SetResolution, /* Not supported, added for compatibility */
71  ADV7533_GetResolution, /* Not supported, added for compatibility */
72  ADV7533_SetProtocol, /* Not supported, added for compatibility */
73  ADV7533_GetProtocol, /* Not supported, added for compatibility */
74  ADV7533_Reset /* Not supported, added for compatibility */
75 };
76 
78 {
98 };
99 
107 static int32_t ADV7533_ReadRegWrap(void *handle, uint16_t Reg, uint8_t* Data, uint16_t Length);
108 static int32_t ADV7533_WriteRegWrap(void *handle, uint16_t Reg, uint8_t* Data, uint16_t Length);
109 static void ADV7533_SetI2C_Address(ADV7533_Object_t *pObj, uint8_t Address);
114 /* Exported functions --------------------------------------------------------*/
124 {
125  int32_t ret;
126 
127  if (pObj == NULL)
128  {
129  ret = ADV7533_ERROR;
130  }
131  else
132  {
133  pObj->IO.Init = pIO->Init;
134  pObj->IO.DeInit = pIO->DeInit;
135  pObj->IO.Address = pIO->Address;
136  pObj->IO.WriteReg = pIO->WriteReg;
137  pObj->IO.ReadReg = pIO->ReadReg;
138  pObj->IO.GetTick = pIO->GetTick;
139 
142  pObj->Ctx.handle = pObj;
143 
144  if(pObj->IO.Init != NULL)
145  {
146  ret = pObj->IO.Init();
147  }
148  else
149  {
150  ret = ADV7533_ERROR;
151  }
152  }
153 
154  return ret;
155 }
156 
157 /*------------------------------------------------------------------------------
158  HDMI video functions
159 ------------------------------------------------------------------------------*/
167 int32_t ADV7533_Init(ADV7533_Object_t *pObj, uint32_t ColorCoding, uint32_t Orientation)
168 {
169  int32_t ret = ADV7533_OK;
170  uint8_t tmp;
171 
172  /* Prevent unused argument(s) compilation warning */
173  (void)(ColorCoding);
174  (void)(Orientation);
175 
176  if(pObj->IsInitialized == 0U)
177  {
178  pObj->IO.Init();
179 
181 
182  /* Configure the IC2 address for CEC_DSI interface */
184  if(adv7533_write_reg(&pObj->Ctx, 0xE1, &tmp, 1) != ADV7533_OK)
185  {
186  ret = ADV7533_ERROR;
187  }
188  else
189  {
190  pObj->IsInitialized = 1;
191  }
192  }
193 
194  return ret;
195 }
196 
203 {
204  if(pObj->IsInitialized == 1U)
205  {
206  /* Deinitialize Audio adv7533 interface */
207  pObj->IO.DeInit();
208 
209  /* Set IsInitialized to 0 */
210  pObj->IsInitialized = 0;
211  }
212 
213  return ADV7533_OK;
214 }
215 
221 int32_t ADV7533_ReadID(ADV7533_Object_t *pObj, uint32_t *Id)
222 {
223  int32_t ret = ADV7533_OK;
224  uint8_t tmp1, tmp2;
225 
226  /* Set I2C address to ADV7533_CEC_DSI_I2C_ADDR */
228 
229  if(adv7533_read_reg(&pObj->Ctx, ADV7533_CHIPID_ADDR0, &tmp1, 1) != ADV7533_OK)
230  {
231  ret = ADV7533_ERROR;
232  }
233  else if(adv7533_read_reg(&pObj->Ctx, ADV7533_CHIPID_ADDR1, &tmp2, 1) != ADV7533_OK)
234  {
235  ret = ADV7533_ERROR;
236  }
237  else
238  {
239  *Id = (uint16_t)(((uint16_t)tmp1 << 8) | tmp2);
240  }
241 
242  return ret;
243 }
244 
251 {
252  int32_t ret = ADV7533_OK;
253  uint8_t tmp;
254 
256  /* Power on */
258  {
259  ret = ADV7533_ERROR;
260  }
261  else
262  {
263  tmp &= ~0x40U;
265  {
266  ret = ADV7533_ERROR;
267  }
268  }
269 
270  return ret;
271 }
272 
279 {
280  int32_t ret = ADV7533_OK;
281  uint8_t tmp;
282 
284  /* Power down */
286  {
287  ret = ADV7533_ERROR;
288  }
289  else
290  {
291  tmp |= 0x40U;
293  {
294  ret = ADV7533_ERROR;
295  }
296  }
297 
298  return ret;
299 }
300 
307 int32_t ADV7533_Configure(ADV7533_Object_t *pObj, uint8_t LaneNumber)
308 {
309  int32_t ret;
310  uint8_t tmp, val;
311 
312  /* ADV7533 Power Settings */
313  /* Set I2C address to ADV7533_MAIN_I2C_ADDR */
315 
316  /* Power down */
317  ret = adv7533_read_reg(&pObj->Ctx, 0x41, &tmp, 1);
318  tmp &= ~0x40U;
319  ret += adv7533_write_reg(&pObj->Ctx, 0x41, &tmp, 1);
320  /* HPD Override */
321  ret += adv7533_read_reg(&pObj->Ctx, 0xD6, &tmp, 1);
322  tmp |= 0x40U;
323  ret += adv7533_write_reg(&pObj->Ctx, 0xD6, &tmp, 1);
324 
325  /* Set I2C address to ADV7533_CEC_DSI_I2C_ADDR */
327 
328  /* Gate DSI LP Oscillator and DSI Bias Clock Powerdown */
329  ret += adv7533_read_reg(&pObj->Ctx, 0x03, &tmp, 1);
330  tmp &= ~0x02U;
331  ret += adv7533_write_reg(&pObj->Ctx, 0x03, &tmp, 1);
332 
333  /* Set I2C address to ADV7533_MAIN_I2C_ADDR */
335  /* Fixed registers that must be set on power-up */
336  ret += adv7533_read_reg(&pObj->Ctx, 0x16, &tmp, 1);
337  tmp &= ~0x3EU;
338  tmp |= 0x20U;
339  ret += adv7533_write_reg(&pObj->Ctx, 0x16, &tmp, 1);
340  val = 0xE0;
341  ret += adv7533_write_reg(&pObj->Ctx, 0x9A, &val, 1);
342  ret += adv7533_read_reg(&pObj->Ctx, 0xBA, &tmp, 1);
343  tmp &= ~0xF8U;
344  tmp |= 0x70U;
345  ret += adv7533_write_reg(&pObj->Ctx, 0xBA, &tmp, 1);
346  val = 0x82;
347  ret += adv7533_write_reg(&pObj->Ctx, 0xDE, &val, 1);
348 
349  ret += adv7533_read_reg(&pObj->Ctx, 0xE4, &tmp, 1);
350  tmp |= 0x40U;
351  ret += adv7533_write_reg(&pObj->Ctx, 0xE4, &tmp, 1);
352  val = 0x80;
353  ret += adv7533_write_reg(&pObj->Ctx, 0xE5, &val, 1);
354 
355  /* Set I2C address to ADV7533_CEC_DSI_I2C_ADDR */
357 
358  ret += adv7533_read_reg(&pObj->Ctx, 0x15, &tmp, 1);
359  tmp &= ~0x30U;
360  tmp |= 0x10U;
361  ret += adv7533_read_reg(&pObj->Ctx, 0x17, &tmp, 1);
362  tmp &= ~0xF0U;
363  tmp |= 0xD0U;
364  ret += adv7533_write_reg(&pObj->Ctx, 0x17, &tmp, 1);
365  ret += adv7533_read_reg(&pObj->Ctx, 0x24, &tmp, 1);
366  tmp &= ~0x10U;
367  ret += adv7533_write_reg(&pObj->Ctx, 0x24, &tmp, 1);
368  ret += adv7533_read_reg(&pObj->Ctx, 0x57, &tmp, 1);
369  tmp |= 0x01U;
370  tmp |= 0x10U;
371  ret += adv7533_write_reg(&pObj->Ctx, 0x57, &tmp, 1);
372 
373  /* Configure the number of DSI lanes */
374  val = (LaneNumber << 4);
375  ret += adv7533_write_reg(&pObj->Ctx, 0x1C, &val, 1);
376 
377  /* Setup video output mode */
378  /* Set I2C address to ADV7533_MAIN_I2C_ADDR */
380 
381  /* Select HDMI mode */
382  ret += adv7533_read_reg(&pObj->Ctx, 0xAF, &tmp, 1);
383  tmp |= 0x02U;
384  ret += adv7533_write_reg(&pObj->Ctx, 0xAF, &tmp, 1);
385 
386  /* Set I2C address to ADV7533_CEC_DSI_I2C_ADDR */
388 
389  /* HDMI Output Enable */
390  ret += adv7533_read_reg(&pObj->Ctx, 0x03, &tmp, 1);
391  tmp |= 0x80U;
392  ret += adv7533_write_reg(&pObj->Ctx, 0x03, &tmp, 1);
393 
394  /* Set I2C address to ADV7533_MAIN_I2C_ADDR */
396 
397  /* GC packet enable */
398  ret += adv7533_read_reg(&pObj->Ctx, 0x40, &tmp, 1);
399  tmp |= 0x80U;
400  ret += adv7533_write_reg(&pObj->Ctx, 0x40, &tmp, 1);
401  /* Input color depth 24-bit per pixel */
402  ret += adv7533_read_reg(&pObj->Ctx, 0x4C, &tmp, 1);
403  tmp &= ~0x0FU;
404  tmp |= 0x03U;
405  ret += adv7533_write_reg(&pObj->Ctx, 0x4C, &tmp, 1);
406  /* Down dither output color depth */
407  val = 0xFC;
408  ret += adv7533_write_reg(&pObj->Ctx, 0x49, &val, 1);
409 
410  /* Set I2C address to ADV7533_CEC_DSI_I2C_ADDR */
412 
413  /* Internal timing disabled */
414  ret += adv7533_read_reg(&pObj->Ctx, 0x27, &tmp, 1);
415  tmp &= ~0x80U;
416  ret += adv7533_write_reg(&pObj->Ctx, 0x27, &tmp, 1);
417 
418  if(ret != ADV7533_OK)
419  {
420  ret = ADV7533_ERROR;
421  }
422 
423  return ret;
424 }
425 
432 {
433  int32_t ret;
434  uint8_t tmp;
435 
436  /* Set I2C address to ADV7533_CEC_DSI_I2C_ADDR */
438 
439  /* Timing generator enable */
440  /* Color bar */
441  tmp = 0x80;
442  ret = adv7533_write_reg(&pObj->Ctx, 0x55, &tmp, 1);
443 
444  if(ret == ADV7533_OK)
445  {
446  tmp = 0xA0;
447  ret += adv7533_write_reg(&pObj->Ctx, 0x55, &tmp, 1);
448  }
449  if(ret == ADV7533_OK)
450  {
451  tmp = 0x89;
452  ret += adv7533_write_reg(&pObj->Ctx, 0x03, &tmp, 1);
453  }
454  if(ret == ADV7533_OK)
455  {
456  tmp = 0x16;
457  ret += adv7533_write_reg(&pObj->Ctx, 0xAF, &tmp, 1);
458  }
459 
460  if(ret != ADV7533_OK)
461  {
462  ret = ADV7533_ERROR;
463  }
464 
465  return ret;
466 }
467 
474 {
475  int32_t ret = ADV7533_OK;
476  uint8_t tmp = 0x00;
477 
478  /* Set I2C address to ADV7533_CEC_DSI_I2C_ADDR */
480 
481  /* Timing generator enable */
482  if(adv7533_write_reg(&pObj->Ctx, 0x55, &tmp, 1) != ADV7533_OK)
483  {
484  ret = ADV7533_ERROR;
485  }
486 
487  return ret;
488 }
489 
496 int32_t ADV7533_SetBrightness(ADV7533_Object_t *pObj, uint32_t Brightness)
497 {
498  /* Prevent unused argument(s) compilation warning */
499  (void)(pObj);
500 
501  return ADV7533_ERROR;
502 }
503 
510 int32_t ADV7533_GetBrightness(ADV7533_Object_t *pObj, uint32_t *Brightness)
511 {
512  /* Prevent unused argument(s) compilation warning */
513  (void)(pObj);
514 
515  return ADV7533_ERROR;
516 }
517 
518 
525 int32_t ADV7533_SetOrientation(ADV7533_Object_t *pObj, uint32_t Orientation)
526 {
527  /* Prevent unused argument(s) compilation warning */
528  (void)(pObj);
529 
530  return ADV7533_ERROR;
531 }
532 
539 int32_t ADV7533_GetOrientation(ADV7533_Object_t *pObj, uint32_t *Orientation)
540 {
541  /* Prevent unused argument(s) compilation warning */
542  (void)(pObj);
543 
544  return ADV7533_ERROR;
545 }
546 
553 int32_t ADV7533_GetXSize(ADV7533_Object_t *pObj, uint32_t *Xsize)
554 {
555  /* Prevent unused argument(s) compilation warning */
556  (void)(pObj);
557 
558 
559  return ADV7533_ERROR;
560 }
561 
568 int32_t ADV7533_GetYSize(ADV7533_Object_t *pObj, uint32_t *Ysize)
569 {
570  /* Prevent unused argument(s) compilation warning */
571  (void)(pObj);
572 
573  return ADV7533_ERROR;
574 }
575 
583 int32_t ADV7533_SetCursor(ADV7533_Object_t *pObj, uint32_t Xpos, uint32_t Ypos)
584 {
585  /* Prevent unused argument(s) compilation warning */
586  (void)(pObj);
587 
588  return ADV7533_ERROR;
589 }
590 
599 int32_t ADV7533_DrawBitmap(ADV7533_Object_t *pObj, uint32_t Xpos, uint32_t Ypos, uint8_t *pBmp)
600 {
601  /* Prevent unused argument(s) compilation warning */
602  (void)(pObj);
603 
604  return ADV7533_ERROR;
605 }
606 
607 int32_t ADV7533_FillRGBRect(ADV7533_Object_t *pObj, uint32_t Xpos, uint32_t Ypos, uint8_t *pData, uint32_t Width, uint32_t Height)
608 {
609  /* Prevent unused argument(s) compilation warning */
610  (void)(pObj);
611 
612  return ADV7533_ERROR;
613 }
623 int32_t ADV7533_DrawHLine(ADV7533_Object_t *pObj, uint32_t Xpos, uint32_t Ypos, uint32_t Length, uint32_t Color)
624 {
625  /* Prevent unused argument(s) compilation warning */
626  (void)(pObj);
627 
628  return ADV7533_ERROR;
629 }
630 
640 int32_t ADV7533_DrawVLine(ADV7533_Object_t *pObj, uint32_t Xpos, uint32_t Ypos, uint32_t Length, uint32_t Color)
641 {
642  /* Prevent unused argument(s) compilation warning */
643  (void)(pObj);
644 
645  return ADV7533_ERROR;
646 }
647 
658 int32_t ADV7533_FillRect(ADV7533_Object_t *pObj, uint32_t Xpos, uint32_t Ypos, uint32_t Width, uint32_t Height, uint32_t Color)
659 {
660  /* Prevent unused argument(s) compilation warning */
661  (void)(pObj);
662 
663  return ADV7533_ERROR;
664 }
665 
674 int32_t ADV7533_GetPixel(ADV7533_Object_t *pObj, uint32_t Xpos, uint32_t Ypos, uint32_t *Color)
675 {
676  /* Prevent unused argument(s) compilation warning */
677  (void)(pObj);
678 
679  return ADV7533_ERROR;
680 }
681 
690 int32_t ADV7533_SetPixel(ADV7533_Object_t *pObj, uint32_t Xpos, uint32_t Ypos, uint32_t Color)
691 {
692  /* Prevent unused argument(s) compilation warning */
693  (void)(pObj);
694 
695  return ADV7533_ERROR;
696 }
697 
698 /*------------------------------------------------------------------------------
699  HDMI Audio functions
700 ------------------------------------------------------------------------------*/
708 {
709  int32_t ret = ADV7533_OK;
710  uint32_t val = 4096U;
711  uint8_t tmp;
712 
713  if(pObj->IsInitialized == 0U)
714  {
715  /* Set I2C address to ADV7533_CEC_DSI_I2C_ADDR */
717 
718  /* Audio data enable*/
719  ret = adv7533_read_reg(&pObj->Ctx, 0x05, &tmp, 1);
720  tmp &= ~0x20U;
721  ret += adv7533_write_reg(&pObj->Ctx, 0x05, &tmp, 1);
722 
723  /* Set I2C address to ADV7533_MAIN_I2C_ADDR */
725 
726  /* HDMI statup */
727  tmp = (uint8_t)((val & 0xF0000U)>>16);
728  ret += adv7533_write_reg(&pObj->Ctx, 0x01, &tmp, 1);
729 
730  tmp= (uint8_t)((val & 0xFF00U)>>8);
731  ret += adv7533_write_reg(&pObj->Ctx, 0x02, &tmp, 1);
732 
733  tmp= (uint8_t)((val & 0xFFU));
734  ret += adv7533_write_reg(&pObj->Ctx, 0x03, &tmp, 1);
735 
736  /* Enable spdif */
737  ret += adv7533_read_reg(&pObj->Ctx, 0x0B, &tmp, 1);
738  tmp |= 0x80U;
739  ret += adv7533_write_reg(&pObj->Ctx, 0x0B, &tmp, 1);
740 
741  /* Enable I2S */
742  ret += adv7533_read_reg(&pObj->Ctx, 0x0C, &tmp, 1);
743  tmp |=0x04U;
744  ret += adv7533_write_reg(&pObj->Ctx, 0x0C, &tmp, 1);
745 
746  /* Set audio sampling frequency */
747  ret += ADV7533_SetFrequency(pObj, pInit->Frequency);
748 
749  /* Select SPDIF is 0x10 , I2S=0x00 */
750  ret += adv7533_read_reg(&pObj->Ctx, 0x0A, &tmp, 1);
751  tmp &=~ 0x10U;
752  ret += adv7533_write_reg(&pObj->Ctx, 0x0A, &tmp, 1);
753 
754  /* Set v1P2 enable */
755  ret += adv7533_read_reg(&pObj->Ctx, 0xE4, &tmp, 1);
756  tmp |= 0x80U;
757  ret += adv7533_write_reg(&pObj->Ctx, 0xE4, &tmp, 1);
758 
759  pObj->IsInitialized = 1;
760  }
761 
762  return ret;
763 }
764 
771 {
772  return(ADV7533_SetMute(pObj, ADV7533_MUTE_ON));
773 }
774 
781 {
782  return(ADV7533_SetMute(pObj, ADV7533_MUTE_OFF));
783 }
784 
792 {
793  return(ADV7533_SetMute(pObj, ADV7533_MUTE_OFF));
794 }
795 
801 int32_t ADV7533_Stop(ADV7533_Object_t *pObj, uint32_t CodecPdwnMode)
802 {
803  /* Prevent unused argument(s) compilation warning */
804  (void)(CodecPdwnMode);
805 
806  return(ADV7533_SetMute(pObj, ADV7533_MUTE_ON));
807 }
808 
816 int32_t ADV7533_SetMute(ADV7533_Object_t *pObj, uint16_t Cmd)
817 {
818  int32_t ret;
819  uint8_t tmp = 0;
820 
821  /* Set I2C address to ADV7533_MAIN_I2C_ADDR */
823 
824  ret = adv7533_read_reg(&pObj->Ctx, 0x0D, &tmp, 1);
825  if (Cmd == ADV7533_MUTE_ON)
826  {
827  /* enable audio mute*/
828  tmp |= 0x40U;
829  if(adv7533_write_reg(&pObj->Ctx, 0x0D, &tmp, 1) != ADV7533_OK)
830  {
831  ret = ADV7533_ERROR;
832  }
833  }
834  else
835  {
836  /*audio mute off disable the mute */
837  tmp &= ~0x40U;
838  if(adv7533_write_reg(&pObj->Ctx, 0x0D, &tmp, 1) != ADV7533_OK)
839  {
840  ret = ADV7533_ERROR;
841  }
842  }
843 
844  return ret;
845 }
846 
853 int32_t ADV7533_SetOutputMode(ADV7533_Object_t *pObj, uint16_t Output)
854 {
855  /* Prevent unused argument(s) compilation warning */
856  (void)(pObj);
857  (void)(Output);
858 
859  /* Not supported */
860  return ADV7533_ERROR;
861 }
862 
869 int32_t ADV7533_SetVolume(ADV7533_Object_t *pObj, uint8_t Volume, uint8_t InputOutput)
870 {
871  /* Prevent unused argument(s) compilation warning */
872  (void)(pObj);
873  (void)(Volume);
874  (void)(InputOutput);
875 
876  /* Not supported */
877  return ADV7533_ERROR;
878 }
879 
886 int32_t ADV7533_GetVolume(ADV7533_Object_t *pObj, uint8_t Volume)
887 {
888  /* Prevent unused argument(s) compilation warning */
889  (void)(pObj);
890  (void)(Volume);
891 
892  /* Not supported */
893  return ADV7533_ERROR;
894 }
895 
902 int32_t ADV7533_SetResolution(ADV7533_Object_t *pObj, uint32_t Resolution)
903 {
904  /* Prevent unused argument(s) compilation warning */
905  (void)(pObj);
906  (void)(Resolution);
907 
908  /* Not supported */
909  return ADV7533_ERROR;
910 }
911 
917 int32_t ADV7533_GetResolution(ADV7533_Object_t *pObj, uint32_t *Resolution)
918 {
919  /* Prevent unused argument(s) compilation warning */
920  (void)(pObj);
921  (void)(Resolution);
922 
923  /* Not supported */
924  return ADV7533_ERROR;
925 }
926 
933 int32_t ADV7533_SetProtocol(ADV7533_Object_t *pObj, uint16_t Protocol)
934 {
935  /* Prevent unused argument(s) compilation warning */
936  (void)(pObj);
937  (void)(Protocol);
938 
939  /* Not supported */
940  return ADV7533_ERROR;
941 }
942 
949 {
950  /* Prevent unused argument(s) compilation warning */
951  (void)(pObj);
952 
953  /* Not supported */
954  return ADV7533_ERROR;
955 }
956 
963 int32_t ADV7533_SetFrequency(ADV7533_Object_t *pObj, uint32_t AudioFreq)
964 {
965  int32_t ret;
966  uint8_t tmp;
967 
968  /* Set I2C address to ADV7533_MAIN_I2C_ADDR */
970 
971  ret = adv7533_read_reg(&pObj->Ctx, 0x15, &tmp, 1);
972  tmp &= (~0xF0U);
973  /* Clock Configurations */
974  switch (AudioFreq)
975  {
977  /* Sampling Frequency =32 KHZ*/
978  tmp |= 0x30U;
979  ret += adv7533_write_reg(&pObj->Ctx, 0x15, &tmp, 1);
980  break;
981  case ADV7533_FREQUENCY_44K:
982  /* Sampling Frequency =44,1 KHZ*/
983  tmp |= 0x00U;
984  ret += adv7533_write_reg(&pObj->Ctx, 0x15, &tmp, 1);
985  break;
986 
987  case ADV7533_FREQUENCY_48K:
988  /* Sampling Frequency =48KHZ*/
989  tmp |= 0x20U;
990  ret += adv7533_write_reg(&pObj->Ctx, 0x15, &tmp, 1);
991  break;
992 
993  case ADV7533_FREQUENCY_96K:
994  /* Sampling Frequency =96 KHZ*/
995  tmp |= 0xA0U;
996  ret += adv7533_write_reg(&pObj->Ctx, 0x15, &tmp, 1);
997  break;
998 
999  case ADV7533_FREQUENCY_88K:
1000  /* Sampling Frequency =88,2 KHZ*/
1001  tmp |= 0x80U;
1002  ret += adv7533_write_reg(&pObj->Ctx, 0x15, &tmp, 1);
1003  break;
1004 
1005  case ADV7533_FREQUENCY_176K:
1006  /* Sampling Frequency =176,4 KHZ*/
1007  tmp |= 0xC0U;
1008  ret += adv7533_write_reg(&pObj->Ctx, 0x15, &tmp, 1);
1009  break;
1010 
1011  case ADV7533_FREQUENCY_192K:
1012  /* Sampling Frequency =192KHZ*/
1013  tmp |= 0xE0U;
1014  ret += adv7533_write_reg(&pObj->Ctx, 0x15, &tmp, 1);
1015  break;
1016  default:
1017  break;
1018  }
1019 
1020  return ret;
1021 }
1022 
1029 int32_t ADV7533_GetFrequency(ADV7533_Object_t *pObj, uint32_t *Frequency)
1030 {
1031  int32_t ret;
1032  uint8_t freq;
1033 
1034  /* Set I2C address to ADV7533_MAIN_I2C_ADDR */
1036 
1037  ret = adv7533_read_reg(&pObj->Ctx, 0x15, &freq, 1);
1038  freq &= 0xF0U;
1039 
1040  /* Clock Configurations */
1041  switch (freq)
1042  {
1043  case 0x30:
1044  /* Sampling Frequency =32 KHZ*/
1045  *Frequency = ADV7533_FREQUENCY_32K;
1046  break;
1047  case 0x00:
1048  /* Sampling Frequency =44,1 KHZ*/
1049  *Frequency = ADV7533_FREQUENCY_44K;
1050  break;
1051 
1052  case 0x20:
1053  /* Sampling Frequency =48KHZ*/
1054  *Frequency = ADV7533_FREQUENCY_48K;
1055  break;
1056 
1057  case 0xA0:
1058  /* Sampling Frequency =96 KHZ*/
1059  *Frequency = ADV7533_FREQUENCY_96K;
1060  break;
1061 
1062  case 0x80:
1063  /* Sampling Frequency =88,2 KHZ*/
1064  *Frequency = ADV7533_FREQUENCY_88K;
1065  break;
1066 
1067  case 0xC0:
1068  /* Sampling Frequency =176,4 KHZ*/
1069  *Frequency = ADV7533_FREQUENCY_176K;
1070  break;
1071 
1072  case 0xE0:
1073  /* Sampling Frequency =192KHZ*/
1074  *Frequency = ADV7533_FREQUENCY_192K;
1075  break;
1076 
1077  default:
1078  break;
1079  }
1080 
1081  return ret;
1082 }
1083 
1090 {
1091  /* Prevent unused argument(s) compilation warning */
1092  (void)(pObj);
1093 
1094  /* Not supported */
1095  return ADV7533_ERROR;
1096 }
1097 
1098 /******************** Static functions ****************************************/
1105 static void ADV7533_SetI2C_Address(ADV7533_Object_t *pObj, uint8_t Address)
1106 {
1107  pObj->IO.Address = Address;
1108 }
1109 
1118 static int32_t ADV7533_ReadRegWrap(void *handle, uint16_t Reg, uint8_t* pData, uint16_t Length)
1119 {
1120  ADV7533_Object_t *pObj = (ADV7533_Object_t *)handle;
1121 
1122  return pObj->IO.ReadReg(pObj->IO.Address, Reg, pData, Length);
1123 }
1124 
1133 static int32_t ADV7533_WriteRegWrap(void *handle, uint16_t Reg, uint8_t* pData, uint16_t Length)
1134 {
1135  ADV7533_Object_t *pObj = (ADV7533_Object_t *)handle;
1136 
1137  return pObj->IO.WriteReg(pObj->IO.Address, Reg, pData, Length);
1138 }
1139 
1156 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
ADV7533_Init_t::Frequency
uint32_t Frequency
Definition: adv7533.h:54
ADV7533_Pause
int32_t ADV7533_Pause(ADV7533_Object_t *pObj)
Pauses playing on the audio hdmi.
Definition: adv7533.c:770
ADV7533_ReadRegWrap
static int32_t ADV7533_ReadRegWrap(void *handle, uint16_t Reg, uint8_t *Data, uint16_t Length)
Function.
Definition: adv7533.c:1118
ADV7533_SetResolution
int32_t ADV7533_SetResolution(ADV7533_Object_t *pObj, uint32_t Resolution)
Set Audio resolution.
Definition: adv7533.c:902
ADV7533_CHIPID_ADDR0
#define ADV7533_CHIPID_ADDR0
Definition: adv7533_reg.h:84
ADV7533_FREQUENCY_48K
#define ADV7533_FREQUENCY_48K
Definition: adv7533.h:139
ADV7533_SetPixel
int32_t ADV7533_SetPixel(ADV7533_Object_t *pObj, uint32_t Xpos, uint32_t Ypos, uint32_t Color)
Set pixel color.
Definition: adv7533.c:690
ADV7533_Init
int32_t ADV7533_Init(ADV7533_Object_t *pObj, uint32_t ColorCoding, uint32_t Orientation)
Initializes the audio codec and the control interface.
Definition: adv7533.c:167
ADV7533_IO_t::GetTick
ADV7533_GetTick_Func GetTick
Definition: adv7533.h:64
ADV7533_FREQUENCY_176K
#define ADV7533_FREQUENCY_176K
Definition: adv7533.h:136
ADV7533_FREQUENCY_88K
#define ADV7533_FREQUENCY_88K
Definition: adv7533.h:138
NULL
#define NULL
Definition: porcupine/demo/c/dr_libs/tests/external/miniaudio/extras/speex_resampler/thirdparty/resample.c:92
ADV7533_IO_t::DeInit
ADV7533_DeInit_Func DeInit
Definition: adv7533.h:60
ADV7533_SetBrightness
int32_t ADV7533_SetBrightness(ADV7533_Object_t *pObj, uint32_t Brightness)
Set the display brightness.
Definition: adv7533.c:496
ADV7533_SetVolume
int32_t ADV7533_SetVolume(ADV7533_Object_t *pObj, uint8_t Volume, uint8_t InputOutput)
Sets volumee.
Definition: adv7533.c:869
adv7533_ctx_t::handle
void * handle
Definition: adv7533_reg.h:110
ADV7533_CEC_DSI_I2C_ADDR
#define ADV7533_CEC_DSI_I2C_ADDR
Definition: adv7533.h:156
ADV7533_ReadID
int32_t ADV7533_ReadID(ADV7533_Object_t *pObj, uint32_t *Id)
Get the adv7533 ID.
Definition: adv7533.c:221
ADV7533_IO_t::ReadReg
ADV7533_ReadReg_Func ReadReg
Definition: adv7533.h:63
ADV7533_DrawBitmap
int32_t ADV7533_DrawBitmap(ADV7533_Object_t *pObj, uint32_t Xpos, uint32_t Ypos, uint8_t *pBmp)
Draw Bitmap image.
Definition: adv7533.c:599
ADV7533_FREQUENCY_192K
#define ADV7533_FREQUENCY_192K
AUDIO FREQUENCY.
Definition: adv7533.h:135
ADV7533_SetCursor
int32_t ADV7533_SetCursor(ADV7533_Object_t *pObj, uint32_t Xpos, uint32_t Ypos)
Set the display cursor.
Definition: adv7533.c:583
ADV7533_RegisterBusIO
int32_t ADV7533_RegisterBusIO(ADV7533_Object_t *pObj, ADV7533_IO_t *pIO)
Function.
Definition: adv7533.c:123
ADV7533_Driver
ADV7533_Drv_t ADV7533_Driver
Definition: adv7533.c:55
ADV7533_MUTE_ON
#define ADV7533_MUTE_ON
Definition: adv7533.h:179
ADV7533_OK
#define ADV7533_OK
Definition: adv7533.h:129
ADV7533_Stop
int32_t ADV7533_Stop(ADV7533_Object_t *pObj, uint32_t CodecPdwnMode)
Stop playing on the audio hdmi.
Definition: adv7533.c:801
ADV7533_DrawHLine
int32_t ADV7533_DrawHLine(ADV7533_Object_t *pObj, uint32_t Xpos, uint32_t Ypos, uint32_t Length, uint32_t Color)
Draw Horizontal Line.
Definition: adv7533.c:623
ADV7533_DeInit
int32_t ADV7533_DeInit(ADV7533_Object_t *pObj)
Deinitializes the adv7533.
Definition: adv7533.c:202
ADV7533_Object_t::Ctx
adv7533_ctx_t Ctx
Definition: adv7533.h:70
adv7533_ctx_t::WriteReg
ADV7533_Write_Func WriteReg
Definition: adv7533_reg.h:108
ADV7533_IO_t::WriteReg
ADV7533_WriteReg_Func WriteReg
Definition: adv7533.h:62
ADV7533_MAIN_I2C_ADDR
#define ADV7533_MAIN_I2C_ADDR
ADV7533 I2C Addresses 0x7A / 0x78.
Definition: adv7533.h:155
ADV7533_SetFrequency
int32_t ADV7533_SetFrequency(ADV7533_Object_t *pObj, uint32_t AudioFreq)
Sets new frequency.
Definition: adv7533.c:963
ADV7533_Init_t
Definition: adv7533.h:52
ADV7533_Drv_t
Definition: adv7533.h:74
ADV7533_FREQUENCY_96K
#define ADV7533_FREQUENCY_96K
Definition: adv7533.h:137
ADV7533_GetFrequency
int32_t ADV7533_GetFrequency(ADV7533_Object_t *pObj, uint32_t *Frequency)
Sets new frequency.
Definition: adv7533.c:1029
ADV7533_AudioInit
int32_t ADV7533_AudioInit(ADV7533_Object_t *pObj, ADV7533_Init_t *pInit)
Initializes the audio codec and the control interface.
Definition: adv7533.c:707
ADV7533_FREQUENCY_44K
#define ADV7533_FREQUENCY_44K
Definition: adv7533.h:140
ADV7533_IO_t::Address
uint16_t Address
Definition: adv7533.h:61
ADV7533_GetVolume
int32_t ADV7533_GetVolume(ADV7533_Object_t *pObj, uint8_t Volume)
Sets volumee.
Definition: adv7533.c:886
ADV7533_Reset
int32_t ADV7533_Reset(ADV7533_Object_t *pObj)
Resets adv7533 registers.
Definition: adv7533.c:1089
ADV7533_GetXSize
int32_t ADV7533_GetXSize(ADV7533_Object_t *pObj, uint32_t *Xsize)
Set the display Width.
Definition: adv7533.c:553
ADV7533_DisplayOff
int32_t ADV7533_DisplayOff(ADV7533_Object_t *pObj)
Power off the ADV7533 bridge.
Definition: adv7533.c:278
ADV7533_CHIPID_ADDR1
#define ADV7533_CHIPID_ADDR1
Definition: adv7533_reg.h:85
ADV7533_MUTE_OFF
#define ADV7533_MUTE_OFF
Definition: adv7533.h:180
ADV7533_SetI2C_Address
static void ADV7533_SetI2C_Address(ADV7533_Object_t *pObj, uint8_t Address)
Configure the DSI-HDMI ADV7533 bridge for video.
Definition: adv7533.c:1105
ADV7533_GetProtocol
int32_t ADV7533_GetProtocol(ADV7533_Object_t *pObj)
Get Audio Protocol.
Definition: adv7533.c:948
ADV7533_LCD_Driver
ADV7533_LcdDrv_t ADV7533_LCD_Driver
Definition: adv7533.c:77
ADV7533_WriteRegWrap
static int32_t ADV7533_WriteRegWrap(void *handle, uint16_t Reg, uint8_t *Data, uint16_t Length)
Function.
Definition: adv7533.c:1133
ADV7533_SetOrientation
int32_t ADV7533_SetOrientation(ADV7533_Object_t *pObj, uint32_t Orientation)
Set the display Orientation.
Definition: adv7533.c:525
ADV7533_SetProtocol
int32_t ADV7533_SetProtocol(ADV7533_Object_t *pObj, uint16_t Protocol)
Set Audio Protocol.
Definition: adv7533.c:933
ADV7533_FREQUENCY_32K
#define ADV7533_FREQUENCY_32K
Definition: adv7533.h:141
ADV7533_MAIN_POWER_DOWN_REG
#define ADV7533_MAIN_POWER_DOWN_REG
Definition: adv7533_reg.h:53
ADV7533_SetOutputMode
int32_t ADV7533_SetOutputMode(ADV7533_Object_t *pObj, uint16_t Output)
Sets output mode.
Definition: adv7533.c:853
ADV7533_Resume
int32_t ADV7533_Resume(ADV7533_Object_t *pObj)
Resumes playing on the audio hdmi.
Definition: adv7533.c:780
adv7533_ctx_t::ReadReg
ADV7533_Read_Func ReadReg
Definition: adv7533_reg.h:109
adv7533_write_reg
int32_t adv7533_write_reg(adv7533_ctx_t *ctx, uint16_t reg, uint8_t *pdata, uint16_t length)
Definition: adv7533_reg.c:73
ADV7533_ERROR
#define ADV7533_ERROR
Definition: adv7533.h:130
ADV7533_IO_t::Init
ADV7533_Init_Func Init
Definition: adv7533.h:59
ADV7533_FillRect
int32_t ADV7533_FillRect(ADV7533_Object_t *pObj, uint32_t Xpos, uint32_t Ypos, uint32_t Width, uint32_t Height, uint32_t Color)
Fill rectangle.
Definition: adv7533.c:658
ADV7533_GetPixel
int32_t ADV7533_GetPixel(ADV7533_Object_t *pObj, uint32_t Xpos, uint32_t Ypos, uint32_t *Color)
Get pixel color.
Definition: adv7533.c:674
adv7533.h
This file contains all the constants parameters for the ADV7533 which is the HDMI bridge between DSI ...
ADV7533_Configure
int32_t ADV7533_Configure(ADV7533_Object_t *pObj, uint8_t LaneNumber)
Configure the DSI-HDMI ADV7533 bridge for video.
Definition: adv7533.c:307
ADV7533_SetMute
int32_t ADV7533_SetMute(ADV7533_Object_t *pObj, uint16_t Cmd)
Enables or disables the mute feature on the audio hdmi.
Definition: adv7533.c:816
ADV7533_GetOrientation
int32_t ADV7533_GetOrientation(ADV7533_Object_t *pObj, uint32_t *Orientation)
Set the display Orientation.
Definition: adv7533.c:539
Output
Output
ADV7533_Object_t
Definition: adv7533.h:67
ADV7533_Play
int32_t ADV7533_Play(ADV7533_Object_t *pObj)
Start the audio hdmi play feature.
Definition: adv7533.c:791
ADV7533_DisplayOn
int32_t ADV7533_DisplayOn(ADV7533_Object_t *pObj)
Power on the ADV7533 bridge.
Definition: adv7533.c:250
ADV7533_IO_t
Definition: adv7533.h:57
ADV7533_GetBrightness
int32_t ADV7533_GetBrightness(ADV7533_Object_t *pObj, uint32_t *Brightness)
Get the display brightness.
Definition: adv7533.c:510
adv7533_read_reg
int32_t adv7533_read_reg(adv7533_ctx_t *ctx, uint16_t reg, uint8_t *pdata, uint16_t length)
Definition: adv7533_reg.c:61
ADV7533_GetYSize
int32_t ADV7533_GetYSize(ADV7533_Object_t *pObj, uint32_t *Ysize)
Set the display Height.
Definition: adv7533.c:568
ADV7533_GetResolution
int32_t ADV7533_GetResolution(ADV7533_Object_t *pObj, uint32_t *Resolution)
Get Audio resolution.
Definition: adv7533.c:917
ADV7533_LcdDrv_t
Definition: adv7533.h:96
Length
Length
ADV7533_PatternEnable
int32_t ADV7533_PatternEnable(ADV7533_Object_t *pObj)
Enable video pattern generation.
Definition: adv7533.c:431
ADV7533_Object_t::IO
ADV7533_IO_t IO
Definition: adv7533.h:69
ADV7533_PatternDisable
int32_t ADV7533_PatternDisable(ADV7533_Object_t *pObj)
Disable video pattern generation.
Definition: adv7533.c:473
ADV7533_FillRGBRect
int32_t ADV7533_FillRGBRect(ADV7533_Object_t *pObj, uint32_t Xpos, uint32_t Ypos, uint8_t *pData, uint32_t Width, uint32_t Height)
Definition: adv7533.c:607
ADV7533_Object_t::IsInitialized
uint8_t IsInitialized
Definition: adv7533.h:71
ADV7533_DrawVLine
int32_t ADV7533_DrawVLine(ADV7533_Object_t *pObj, uint32_t Xpos, uint32_t Ypos, uint32_t Length, uint32_t Color)
Draw Vertical line.
Definition: adv7533.c:640


picovoice_driver
Author(s):
autogenerated on Fri Apr 1 2022 02:13:47