@@ -537,6 +537,7 @@ static int hx8394_init(const struct device *dev)
537
537
{
538
538
const struct hx8394_config * config = dev -> config ;
539
539
int ret ;
540
+ ssize_t ret_tx ;
540
541
struct mipi_dsi_device mdev ;
541
542
uint8_t param [2 ];
542
543
uint8_t setmipi [7 ] = {
@@ -588,68 +589,71 @@ static int hx8394_init(const struct device *dev)
588
589
k_sleep (K_MSEC (50 ));
589
590
}
590
591
/* Enable extended commands */
591
- ret = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
592
+ ret_tx = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
592
593
enable_extension , sizeof (enable_extension ));
593
- if (ret < 0 ) {
594
- return ret ;
594
+ if (ret_tx < 0 ) {
595
+ LOG_ERR ("hx8394_mipi_tx error, %d" , ret_tx );
596
+ return - EIO ;
595
597
}
596
598
597
599
/* Set the number of lanes to DSISETUP0 parameter */
598
600
setmipi [1 ] |= (config -> num_of_lanes - 1 );
599
- ret = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
601
+ ret_tx = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
600
602
setmipi , sizeof (setmipi ));
601
- if (ret < 0 ) {
602
- return ret ;
603
+ if (ret_tx < 0 ) {
604
+ LOG_ERR ("hx8394_mipi_tx error, %d" , ret_tx );
605
+ return - EIO ;
603
606
}
604
607
605
608
/* Set scan direction */
606
- ret = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
609
+ ret_tx = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
607
610
address_config , sizeof (address_config ));
608
- if (ret < 0 ) {
609
- return ret ;
611
+ if (ret_tx < 0 ) {
612
+ LOG_ERR ("hx8394_mipi_tx error, %d" , ret_tx );
613
+ return - EIO ;
610
614
}
611
615
612
616
/* Set voltage and current targets */
613
- ret = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
617
+ ret_tx = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
614
618
power_config , sizeof (power_config ));
615
- if (ret < 0 ) {
616
- return ret ;
619
+ if (ret_tx < 0 ) {
620
+ return - EIO ;
617
621
}
618
622
619
623
/* Setup display line count and front/back porch size */
620
- ret = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
624
+ ret_tx = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
621
625
line_config , sizeof (line_config ));
622
- if (ret < 0 ) {
623
- return ret ;
626
+ if (ret_tx < 0 ) {
627
+ return - EIO ;
624
628
}
625
629
626
630
/* Setup display cycle counts (in counts of TCON CLK) */
627
- ret = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
631
+ ret_tx = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
628
632
cycle_config , sizeof (cycle_config ));
629
- if (ret < 0 ) {
630
- return ret ;
633
+ if (ret_tx < 0 ) {
634
+ return - EIO ;
631
635
}
632
636
633
637
/* Set group delay values */
634
- ret = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
638
+ ret_tx = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
635
639
gip0_config , sizeof (gip0_config ));
636
- if (ret < 0 ) {
637
- return ret ;
640
+ if (ret_tx < 0 ) {
641
+ return - EIO ;
638
642
}
639
643
640
644
641
645
/* Set group clock selections */
642
- ret = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
646
+ ret_tx = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
643
647
gip1_config , sizeof (gip1_config ));
644
- if (ret < 0 ) {
645
- return ret ;
648
+ if (ret_tx < 0 ) {
649
+ return - EIO ;
646
650
}
647
651
648
652
/* Set group clock selections for GS mode */
649
- ret = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
653
+ ret_tx = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
650
654
gip2_config , sizeof (gip2_config ));
651
- if (ret < 0 ) {
652
- return ret ;
655
+ if (ret_tx < 0 ) {
656
+ return - EIO ;
653
657
}
654
658
655
659
/* Delay for a moment before setting VCOM. It is not clear
@@ -658,116 +662,119 @@ static int hx8394_init(const struct device *dev)
658
662
*/
659
663
k_msleep (1 );
660
664
/* Set VCOM voltage config */
661
- ret = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
665
+ ret_tx = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
662
666
vcom_config , sizeof (vcom_config ));
663
- if (ret < 0 ) {
664
- return ret ;
667
+ if (ret_tx < 0 ) {
668
+ return - EIO ;
665
669
}
666
670
667
671
/* Set manufacturer supplied gamma values */
668
- ret = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
672
+ ret_tx = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
669
673
gamma_config , sizeof (gamma_config ));
670
- if (ret < 0 ) {
671
- return ret ;
674
+ if (ret_tx < 0 ) {
675
+ return - EIO ;
672
676
}
673
677
674
678
/* This command is not documented in datasheet, but is included
675
679
* in the display initialization done by MCUXpresso SDK
676
680
*/
677
- ret = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
681
+ ret_tx = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
678
682
hx8394_cmd1 , sizeof (hx8394_cmd1 ));
679
- if (ret < 0 ) {
680
- return ret ;
683
+ if (ret_tx < 0 ) {
684
+ return - EIO ;
681
685
}
682
686
683
687
/* Set panel to BGR mode, and reverse colors */
684
- ret = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
688
+ ret_tx = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
685
689
panel_config , sizeof (panel_config ));
686
- if (ret < 0 ) {
687
- return ret ;
690
+ if (ret_tx < 0 ) {
691
+ return - EIO ;
688
692
}
689
693
690
694
/* This command is not documented in datasheet, but is included
691
695
* in the display initialization done by MCUXpresso SDK
692
696
*/
693
- ret = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
697
+ ret_tx = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
694
698
hx8394_cmd2 , sizeof (hx8394_cmd2 ));
695
- if (ret < 0 ) {
696
- return ret ;
699
+ if (ret_tx < 0 ) {
700
+ return - EIO ;
697
701
}
698
702
699
703
/* Write values to manufacturer register banks */
700
704
param [0 ] = HX8394_SETBANK ;
701
705
param [1 ] = 0x2 ;
702
- ret = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
706
+ ret_tx = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
703
707
param , 2 );
704
- if (ret < 0 ) {
705
- return ret ;
708
+ if (ret_tx < 0 ) {
709
+ return - EIO ;
706
710
}
707
- ret = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
711
+ ret_tx = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
708
712
hx8394_bank2 , sizeof (hx8394_bank2 ));
709
- if (ret < 0 ) {
710
- return ret ;
713
+ if (ret_tx < 0 ) {
714
+ return - EIO ;
711
715
}
712
716
param [1 ] = 0x0 ;
713
- ret = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
717
+ ret_tx = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
714
718
param , 2 );
715
- if (ret < 0 ) {
716
- return ret ;
719
+ if (ret_tx < 0 ) {
720
+ return - EIO ;
717
721
}
718
722
/* Select bank 1 */
719
723
param [1 ] = 0x1 ;
720
- ret = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
724
+ ret_tx = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
721
725
param , 2 );
722
- if (ret < 0 ) {
723
- return ret ;
726
+ if (ret_tx < 0 ) {
727
+ return - EIO ;
724
728
}
725
- ret = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
729
+ ret_tx = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
726
730
hx8394_bank1 , sizeof (hx8394_bank1 ));
727
- if (ret < 0 ) {
728
- return ret ;
731
+ if (ret_tx < 0 ) {
732
+ return - EIO ;
729
733
}
730
734
/* Select bank 0 */
731
735
param [1 ] = 0x0 ;
732
- ret = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
736
+ ret_tx = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
733
737
param , 2 );
734
- if (ret < 0 ) {
735
- return ret ;
738
+ if (ret_tx < 0 ) {
739
+ return - EIO ;
736
740
}
737
- ret = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
741
+ ret_tx = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
738
742
hx8394_bank0 , sizeof (hx8394_bank0 ));
739
- if (ret < 0 ) {
740
- return ret ;
743
+ if (ret_tx < 0 ) {
744
+ return - EIO ;
741
745
}
742
746
743
747
/* This command is not documented in datasheet, but is included
744
748
* in the display initialization done by MCUXpresso SDK
745
749
*/
746
- ret = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
750
+ ret_tx = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
747
751
hx8394_cmd3 , sizeof (hx8394_cmd3 ));
748
- if (ret < 0 ) {
749
- return ret ;
752
+ if (ret_tx < 0 ) {
753
+ return - EIO ;
750
754
}
751
755
752
- ret = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
756
+ ret_tx = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
753
757
tear_config , sizeof (tear_config ));
754
- if (ret < 0 ) {
755
- return ret ;
758
+ if (ret_tx < 0 ) {
759
+ return - EIO ;
756
760
}
757
761
758
762
param [0 ] = MIPI_DCS_EXIT_SLEEP_MODE ;
759
763
760
- ret = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
764
+ ret_tx = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
761
765
param , 1 );
762
- if (ret < 0 ) {
763
- return ret ;
766
+ if (ret_tx < 0 ) {
767
+ return - EIO ;
764
768
}
765
769
/* We must delay 120ms after exiting sleep mode per datasheet */
766
770
k_sleep (K_MSEC (120 ));
767
771
768
772
param [0 ] = MIPI_DCS_SET_DISPLAY_ON ;
769
- ret = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
773
+ ret_tx = hx8394_mipi_tx (config -> mipi_dsi , config -> channel ,
770
774
param , 1 );
775
+ if (ret_tx != 1 ) {
776
+ return - EIO ;
777
+ }
771
778
772
779
if (config -> bl_gpio .port != NULL ) {
773
780
ret = gpio_pin_configure_dt (& config -> bl_gpio , GPIO_OUTPUT_ACTIVE );
@@ -777,7 +784,7 @@ static int hx8394_init(const struct device *dev)
777
784
}
778
785
}
779
786
780
- return ret ;
787
+ return 0 ;
781
788
}
782
789
783
790
#define HX8394_PANEL (id ) \
0 commit comments