How to reduce the brightness of the OLED(MIPI) display

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How to reduce the brightness of the OLED(MIPI) display

4,525件の閲覧回数
nandishguruling
Contributor III

Hello ALL,

    i am using the OLED display (DLC0139AZOG-1) with imx6DL board,  i want to reduce the brightness of this display,

   for this i need to control the  SWIRE Pin which has address of ( 0x2Ah for mipi address) and i wrote in driver which is not

   change anything on display, please  any one can see the below code and tell me what wrong i did in the code,

   in the below code in macros is i changed some vaues i commented like //Brightness Related Start & End after changing

   those values while booting time display brightnes is less after complete the booting the display brightness is high,


#include <linux/types.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/platform_device.h>
#include <linux/err.h>
#include <linux/clk.h>
#include <linux/console.h>
#include <linux/io.h>
#include <linux/bitops.h>
#include <linux/spinlock.h>
#include <linux/mipi_dsi.h>
#include <linux/mxcfb.h>
#include <linux/backlight.h>
#include <video/mipi_display.h>

#include "mipi_dsi.h"

#define MIPI_DSI_MAX_RET_PACK_SIZE                (0x4)
//it was 255 on both max and def
#define HX8369BL_MAX_BRIGHT        (255)
#define HX8369BL_DEF_BRIGHT        (128)

#define HX8369_MAX_DPHY_CLK                    (800)
#define HX8369_ONE_DATA_LANE                    (0x1)
#define HX8369_TWO_DATA_LANE                    (0x2)

#define HX8369_CMD_SETEXTC                    (0xB9)
#define HX8369_CMD_SETEXTC_LEN                    (0x4)
#define HX8369_CMD_SETEXTC_PARAM_1                (0x6983ff)

#define HX8369_CMD_GETHXID                    (0xF4)
#define HX8369_CMD_GETHXID_LEN                    (0x4)
#define HX8369_ID                        (0x69)
#define HX8369_ID_MASK                        (0xFF)

#define HX8369_CMD_SETDISP                    (0xB2)
#define HX8369_CMD_SETDISP_LEN                    (16)
#define HX8369_CMD_SETDISP_1_HALT                (0x00)
#define HX8369_CMD_SETDISP_2_RES_MODE                (0x23)
#define HX8369_CMD_SETDISP_3_BP                    (0x03)
#define HX8369_CMD_SETDISP_4_FP                    (0x03)
#define HX8369_CMD_SETDISP_5_SAP                (0x70)
#define HX8369_CMD_SETDISP_6_GENON                (0x00)
#define HX8369_CMD_SETDISP_7_GENOFF                (0xff)
#define HX8369_CMD_SETDISP_8_RTN                (0x00)
#define HX8369_CMD_SETDISP_9_TEI                (0x00)
#define HX8369_CMD_SETDISP_10_TEP_UP                (0x00)
#define HX8369_CMD_SETDISP_11_TEP_LOW                (0x00)
#define HX8369_CMD_SETDISP_12_BP_PE                (0x03)
#define HX8369_CMD_SETDISP_13_FP_PE                (0x03)
#define HX8369_CMD_SETDISP_14_RTN_PE                (0x00)
#define HX8369_CMD_SETDISP_15_GON                (0x01)

#define HX8369_CMD_SETCYC                    (0xB4)
#define HX8369_CMD_SETCYC_LEN                    (6)
#define HX8369_CMD_SETCYC_PARAM_1                (0x5f1d00)
#define HX8369_CMD_SETCYC_PARAM_2                (0x060e)

#define HX8369_CMD_SETGIP                    (0xD5)
#define HX8369_CMD_SETGIP_LEN                    (27)
#define HX8369_CMD_SETGIP_PARAM_1                (0x030400)
#define HX8369_CMD_SETGIP_PARAM_2                (0x1c050100)
#define HX8369_CMD_SETGIP_PARAM_3                (0x00030170)
#define HX8369_CMD_SETGIP_PARAM_4                (0x51064000)
#define HX8369_CMD_SETGIP_PARAM_5                (0x41000007)
#define HX8369_CMD_SETGIP_PARAM_6                (0x07075006)
#define HX8369_CMD_SETGIP_PARAM_7                (0x040f)

#define HX8369_CMD_SETPOWER                    (0xB1)
#define HX8369_CMD_SETPOWER_LEN                    (20)
#define HX8369_CMD_SETPOWER_PARAM_1                (0x340001)
#define HX8369_CMD_SETPOWER_PARAM_2                (0x0f0f0006)
#define HX8369_CMD_SETPOWER_PARAM_3                (0x3f3f322a)
#define HX8369_CMD_SETPOWER_PARAM_4                (0xe6013a07)
#define HX8369_CMD_SETPOWER_PARAM_5                (0xe6e6e6e6)

#define HX8369_CMD_SETVCOM                    (0xB6)
#define HX8369_CMD_SETVCOM_LEN                    (3)
#define HX8369_CMD_SETVCOM_PARAM_1                (0x5656)

#define HX8369_CMD_SETPANEL                    (0xCC)
#define HX8369_CMD_SETPANEL_PARAM_1                (0x02)

#define HX8369_CMD_SETGAMMA                    (0xE0)
#define HX8369_CMD_SETGAMMA_LEN                    (35)
#define HX8369_CMD_SETGAMMA_PARAM_1                (0x221d00)
#define HX8369_CMD_SETGAMMA_PARAM_2                (0x2e3f3d38)
#define HX8369_CMD_SETGAMMA_PARAM_3                (0x0f0d064a)
#define HX8369_CMD_SETGAMMA_PARAM_4                (0x16131513)
#define HX8369_CMD_SETGAMMA_PARAM_5                (0x1d001910)
#define HX8369_CMD_SETGAMMA_PARAM_6                (0x3f3d3822)
#define HX8369_CMD_SETGAMMA_PARAM_7                (0x0d064a2e)
#define HX8369_CMD_SETGAMMA_PARAM_8                (0x1315130f)
#define HX8369_CMD_SETGAMMA_PARAM_9                (0x191016)

#define HX8369_CMD_SETMIPI                    (0xBA)
#define HX8369_CMD_SETMIPI_LEN                    (14)
#define HX8369_CMD_SETMIPI_PARAM_1                (0xc6a000)
#define HX8369_CMD_SETMIPI_PARAM_2                (0x10000a00)
#define HX8369_CMD_SETMIPI_ONELANE                (0x10 << 24)
#define HX8369_CMD_SETMIPI_TWOLANE                (0x11 << 24)
#define HX8369_CMD_SETMIPI_PARAM_3                (0x00026f30)
#define HX8369_CMD_SETMIPI_PARAM_4                (0x4018)

#define HX8369_CMD_SETPIXEL_FMT                    (0x3A)
#define HX8369_CMD_SETPIXEL_FMT_24BPP                (0x77)
#define HX8369_CMD_SETPIXEL_FMT_18BPP                (0x66)
#define HX8369_CMD_SETPIXEL_FMT_16BPP                (0x55)

#define HX8369_CMD_SETCLUMN_ADDR                (0x2A)
#define HX8369_CMD_SETCLUMN_ADDR_LEN                (5)
#define HX8369_CMD_SETCLUMN_ADDR_PARAM_1            (0xdf0000)
#define HX8369_CMD_SETCLUMN_ADDR_PARAM_2            (0x01)

#define HX8369_CMD_SETPAGE_ADDR                    (0x2B)
#define HX8369_CMD_SETPAGE_ADDR_LEN                (5)
#define HX8369_CMD_SETPAGE_ADDR_PARAM_1                (0x1f0000)
#define HX8369_CMD_SETPAGE_ADDR_PARAM_2                (0x03)

//Brightness Related  Start
#define HX8369_CMD_WRT_DISP_BRIGHT                (0x51)
#define HX8369_CMD_WRT_DISP_BRIGHT_PARAM_1            (0x80)
//FF up it was
#define HX8369_CMD_WRT_CABC_MIN_BRIGHT                (0x5E)
#define HX8369_CMD_WRT_CABC_MIN_BRIGHT_PARAM_1            (0x10)
//20 up it was
#define HX8369_CMD_WRT_CABC_CTRL                (0x55)
#define HX8369_CMD_WRT_CABC_CTRL_PARAM_1            (0x0)
//1 up it was
#define HX8369_CMD_WRT_CTRL_DISP                (0x53)
#define HX8369_CMD_WRT_CTRL_DISP_PARAM_1            (0x24)

//Brightness Related End
#define CHECK_RETCODE(ret)                    \
do {                                \
    if (ret < 0) {                        \
        dev_err(&mipi_dsi->pdev->dev,            \
            "%s ERR: ret:%d, line:%d.\n",        \
            __func__, ret, __LINE__);        \
        return ret;                    \
    }                            \
} while (0)

static int hx8369bl_brightness;
static int mipid_init_backlight(struct mipi_dsi_info *mipi_dsi);

static struct fb_videomode truly_lcd_modedb[] = {
    {
     "TRULY-WVGA", 60, 400, 400, 69643,
     40, 20,
     12, 20,
     20, 4,
     FB_SYNC_OE_LOW_ACT,
     FB_VMODE_NONINTERLACED,
     0,
    },
};

static struct mipi_lcd_config lcd_config = {
    .virtual_ch    = 0,
    .data_lane_num  = 1,
    .max_phy_clk    = 350,
    .dpi_fmt    = MIPI_RGB888,
};
void mipid_hx8369_get_lcd_videomode(struct fb_videomode **mode, int *size,
        struct mipi_lcd_config **data)
{       
        printk(" MIPI DRIVER IS READY\n\n\n\n");
    *mode = &truly_lcd_modedb[0];
    *size = ARRAY_SIZE(truly_lcd_modedb);
    *data = &lcd_config;
}

int mipid_hx8369_lcd_setup(struct mipi_dsi_info *mipi_dsi)
{
    u32 buf[DSI_CMD_BUF_MAXSIZE];
    int err;
        printk(" MIPI LCD SETUP IS CALLED\n\n\n\n");

    buf[0] = MIPI_DSI_MAX_RET_PACK_SIZE;
    err = mipi_dsi_pkt_write(mipi_dsi,
                MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE,
                buf, 0);
    CHECK_RETCODE(err);

//SWIRE ADDRESS
        buf[0] = 0x2A;
    err = mipi_dsi_pkt_write(mipi_dsi, MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM,
        buf, 0);
    CHECK_RETCODE(err);


    /* Set power: standby, DC etc. */
    buf[0] = HX8369_CMD_SETPOWER | (HX8369_CMD_SETPOWER_PARAM_1 << 8);
    buf[1] = HX8369_CMD_SETPOWER_PARAM_2;
    buf[2] = HX8369_CMD_SETPOWER_PARAM_3;
    buf[3] = HX8369_CMD_SETPOWER_PARAM_4;
    buf[4] = HX8369_CMD_SETPOWER_PARAM_5;
    err = mipi_dsi_pkt_write(mipi_dsi, MIPI_DSI_GENERIC_LONG_WRITE, buf,
                HX8369_CMD_SETPOWER_LEN);
    CHECK_RETCODE(err);


/* Set display brightness related */
    buf[0] = HX8369_CMD_WRT_DISP_BRIGHT |
            (HX8369_CMD_WRT_DISP_BRIGHT_PARAM_1 << 8);
    err = mipi_dsi_pkt_write(mipi_dsi, MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM,
        buf, 0);
    CHECK_RETCODE(err);                                                                            

    buf[0] = HX8369_CMD_WRT_CABC_CTRL |
        (HX8369_CMD_WRT_CABC_CTRL_PARAM_1 << 8);
    err = mipi_dsi_pkt_write(mipi_dsi, MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM,
        buf, 0);
    CHECK_RETCODE(err);

    buf[0] = HX8369_CMD_WRT_CTRL_DISP |
        (HX8369_CMD_WRT_CTRL_DISP_PARAM_1 << 8);
    err = mipi_dsi_pkt_write(mipi_dsi, MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM,
        buf, 0);
    CHECK_RETCODE(err);

    /* exit sleep mode and set display on */
    buf[0] = MIPI_DCS_EXIT_SLEEP_MODE;
    err = mipi_dsi_pkt_write(mipi_dsi, MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM,
        buf, 0);
    CHECK_RETCODE(err);
    /* To allow time for the supply voltages
     * and clock circuits to stabilize.
     */
    msleep(5);
    buf[0] = MIPI_DCS_SET_DISPLAY_ON;
    err = mipi_dsi_pkt_write(mipi_dsi, MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM,
        buf, 0);
    CHECK_RETCODE(err);

    err = mipid_init_backlight(mipi_dsi);
    return err;
}

static int mipid_bl_update_status(struct backlight_device *bl)
{
    u32 buf;
    int brightness = bl->props.brightness;
        printk(" MIPI LCD BL UPDATE STATUS:\n\n\n\n");
    struct mipi_dsi_info *mipi_dsi = bl_get_data(bl);

    if (bl->props.power != FB_BLANK_UNBLANK ||
        bl->props.fb_blank != FB_BLANK_UNBLANK)
        brightness = 0;

    buf = HX8369_CMD_WRT_DISP_BRIGHT |
            ((brightness & HX8369BL_MAX_BRIGHT) << 8);
    mipi_dsi_pkt_write(mipi_dsi, MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM,
        &buf, 0);

    hx8369bl_brightness = brightness & HX8369BL_MAX_BRIGHT;

    dev_dbg(&bl->dev, "mipid backlight bringtness:%d.\n", brightness);
    return 0;
}

static int mipid_bl_get_brightness(struct backlight_device *bl)
{
    return hx8369bl_brightness;
}

static int mipi_bl_check_fb(struct backlight_device *bl, struct fb_info *fbi)
{
    return 0;
}

static const struct backlight_ops mipid_lcd_bl_ops = {
    .update_status = mipid_bl_update_status,
    .get_brightness = mipid_bl_get_brightness,
    .check_fb = mipi_bl_check_fb,
};

static int mipid_init_backlight(struct mipi_dsi_info *mipi_dsi)
{
        
    struct backlight_properties props;
    struct backlight_device    *bl;
        
    if (mipi_dsi->bl) {
        pr_debug("mipid backlight already init!\n");
        return 0;
    }
        printk(" MIPI LCD INIT BACKLIGHT\n\n\n\n");//nand
    memset(&props, 0, sizeof(struct backlight_properties));
    props.max_brightness = HX8369BL_MAX_BRIGHT;
    props.type = BACKLIGHT_RAW;
    bl = backlight_device_register("mipid-bl", &mipi_dsi->pdev->dev,
        mipi_dsi, &mipid_lcd_bl_ops, &props);
    if (IS_ERR(bl)) {
        pr_err("error %ld on backlight register\n", PTR_ERR(bl));
        return PTR_ERR(bl);
    }
    mipi_dsi->bl = bl;
    bl->props.power = FB_BLANK_UNBLANK;
    bl->props.fb_blank = FB_BLANK_UNBLANK;
    bl->props.brightness = HX8369BL_DEF_BRIGHT;

    mipid_bl_update_status(bl);
    return 0;
}

Thanks in advance

best regards

nandish sg

0 件の賞賛
11 返答(返信)

3,413件の閲覧回数
nandishguruling
Contributor III

Hi Daniel,

You can control the brightness of MIPI Display from user space by giving the commands for brightness,

in terminal   "echo 255 > /sys/class/backlight/mipid-bl/brightness" , (0 to 255 is brightness value), 

Best Regards

Nandish SG

0 件の賞賛

3,412件の閲覧回数
nandishguruling
Contributor III

Hi All,

      I resolved the Issue of Brightness Control of MIPI Display and Thanks to Igor for Helping in this issue.

Best Regards

Nandish SG    

0 件の賞賛

3,413件の閲覧回数
danielgarbanzoh
Contributor I

Hi Nandish,

Could you please tell me how do you resolve the Brightness Control of MIPI Display issue? Did you use a different approach from the mentioned above? 

I am trying to expose Brightness Control of MIPI Display from user_space, so you issue fix may help me a lot.

Thanks in advance!

Best regards,

-Daniel 

0 件の賞賛

3,413件の閲覧回数
nandishguruling
Contributor III

Hi Igor,

can you please have a look for reading the brightness in terminal, when i give the 128 in brightness it shows the voltage as 3.3v,

root@imx6dlsabreauto:/sys/class/backlight/mipid-bl# cat brightness
50
root@imx6dlsabreauto:/sys/class/backlight/mipid-bl# echo 128 > brightness
WHAT BRIGHTNESS I GET = 128

 MIPI LCD BL UPDATE STATUS:

 MIPI LCD BL FB_BLANK_UNBLANK= 0

NOW BRIGHTNESS I GET = 128

mipi_dsi_pkt_write BUF = 32810

MIPI_DSI_CMD_PKT_STATUS val = 0x1515

root@imx6dlsabreauto:/sys/class/backlight/mipid-bl# cat brightness
128
root@imx6dlsabreauto:/sys/class/backlight/mipid-bl# cat actual_brightness
128
root@imx6dlsabreauto:/sys/class/backlight/mipid-bl# cat max_brightness
128
root@imx6dlsabreauto:/sys/class/backlight/mipid-bl#

when change it to 64 in brightness value it shows the voltage as again 3.3v. i am expecting the low voltage(whether i am correct or wrong please tell me),

root@imx6dlsabreauto:/sys/class/backlight/mipid-bl# echo 64 > brightness
WHAT BRIGHTNESS I GET = 64

MIPI LCD BL UPDATE STATUS:

MIPI LCD BL FB_BLANK_UNBLANK= 0

NOW BRIGHTNESS I GET = 64

mipi_dsi_pkt_write BUF = 42

MIPI_DSI_CMD_PKT_STATUS val = 0x1515

root@imx6dlsabreauto:/sys/class/backlight/mipid-bl# cat actual_brightness
0
root@imx6dlsabreauto:/sys/class/backlight/mipid-bl# cat brightness
64
root@imx6dlsabreauto:/sys/class/backlight/mipid-bl# cat max_brightness
128
root@imx6dlsabreauto:/sys/class/backlight/mipid-bl#

can any one please suggest me where i am wrong,

thanks in advance

best regards

Nandish sg

0 件の賞賛

3,413件の閲覧回数
nandishguruling
Contributor III

Hi igor,

yes i check with the DLC Datasheet they are mentioned in datasheet  this value

pastedImage_1.png

in Application notes they mentioned that

(2A80h) SWIRE Control

(8F80h) DIMCTR

(9080h) DIMCTRDP1

(9180h) DIMCTRDP2

(9280h) DIMCTRDP3

i tried all the above values in place of " HX8369_CMD_WRT_DISP_BRIGHT"

 /* Set display brightness related */
    buf[0] = HX8369_CMD_WRT_DISP_BRIGHT |
            (HX8369_CMD_WRT_DISP_BRIGHT_PARAM_1 << 8);
    err = mipi_dsi->mipi_dsi_pkt_write(mipi_dsi, MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM,
        buf, 0);
    CHECK_RETCODE(err);

but i am not seen any change in the display

Thanks in advance

BR

nandish sg

0 件の賞賛

3,413件の閲覧回数
igorpadykov
NXP Employee
NXP Employee

Hi nandish

 

one can check real brightness reading it back.

 

Best regards
igor

0 件の賞賛

3,413件の閲覧回数
nandishguruling
Contributor III

Hi igor,

Thanks for your reply, i set the HX8369_CMD_WRT_DISP_BRIGHT_PARAM_1 = 0xFF is default value and  i changed to 0x80, no change in display,  you can see the my first mail on top i added 2 pics while boot time brightness is low after booting brightness is high,

thanks in advance

BR

nandish sg

0 件の賞賛

3,413件の閲覧回数
igorpadykov
NXP Employee
NXP Employee

Hi nandish

one can check OLED display DLC0139AZOG datasheet

for brightness commands.

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛

3,413件の閲覧回数
nandishguruling
Contributor III

Hi igor,

Thank you for your feedback, i am using the same driver what you mentioned in the above reply, 

git/drivers/video/mxc/mxcfb_hx8363_wvga.c , but no change in display,

Thanks in advance

BR

nandish  sg

0 件の賞賛

3,413件の閲覧回数
igorpadykov
NXP Employee
NXP Employee

Hi nandish

 

there is example in mxcfb_hx8369_wvga.c function mipid_hx8369_lcd_setup() :

    /* Set display brightness related */
    buf[0] = HX8369_CMD_WRT_DISP_BRIGHT |
            (HX8369_CMD_WRT_DISP_BRIGHT_PARAM_1 << 8);
    err = mipi_dsi->mipi_dsi_pkt_write(mipi_dsi, MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM,
        buf, 0);
    CHECK_RETCODE(err); ..

Best regards
igor

0 件の賞賛

3,413件の閲覧回数
igorpadykov
NXP Employee
NXP Employee

Hi nandish

please look at brightness example on
linux/drivers/video/fbdev/mxc/mxcfb_hx8363_wvga.c

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛