Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Linux/drivers/video/fbdev/omap/   (Linux Kernel Version 6.17.9©)  Datei vom 24.10.2025 mit Größe 13 kB image not shown  

Quelle  lcd_mipid.c   Sprache: C

 

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * LCD driver for MIPI DBI-C / DCS compatible LCDs
 *
 * Copyright (C) 2006 Nokia Corporation
 * Author: Imre Deak <imre.deak@nokia.com>
 */

#include <linux/device.h>
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/slab.h>
#include <linux/workqueue.h>
#include <linux/spi/spi.h>
#include <linux/module.h>

#include <linux/platform_data/lcd-mipid.h>

#include "omapfb.h"

#define MIPID_MODULE_NAME  "lcd_mipid"

#define MIPID_CMD_READ_DISP_ID  0x04
#define MIPID_CMD_READ_RED  0x06
#define MIPID_CMD_READ_GREEN  0x07
#define MIPID_CMD_READ_BLUE  0x08
#define MIPID_CMD_READ_DISP_STATUS 0x09
#define MIPID_CMD_RDDSDR  0x0F
#define MIPID_CMD_SLEEP_IN  0x10
#define MIPID_CMD_SLEEP_OUT  0x11
#define MIPID_CMD_DISP_OFF  0x28
#define MIPID_CMD_DISP_ON  0x29

#define MIPID_ESD_CHECK_PERIOD  msecs_to_jiffies(5000)

#define to_mipid_device(p)  container_of(p, struct mipid_device, \
      panel)
struct mipid_device {
 int  enabled;
 int  revision;
 unsigned int saved_bklight_level;
 unsigned long hw_guard_end;  /* next value of jiffies
         when we can issue the
   next sleep in/out command */

 unsigned long hw_guard_wait;  /* max guard time in jiffies */
 struct gpio_desc *reset;

 struct omapfb_device *fbdev;
 struct spi_device *spi;
 struct mutex  mutex;
 struct lcd_panel panel;

 struct delayed_work esd_work;
 void   (*esd_check)(struct mipid_device *m);
};

static/*
      int wlen, u8*rbuf, int rlen)
{
 struct spi_message m;
 struct spi_transfer *x, xfer[4];
 u16   w;
 int   r;

 BUG_ON(md->spi == NULL);

 spi_message_init(&m);

 memset(xfer, 0
 x x = &xfer[0];

 cmd &=  0xff;
 x-> */
 x-> = 9;
 x>len   2;
 (x,

 if (wlen) {
  x++;
  x-t  =wbuf;
 java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 33
  xord=9;
 spi_message_add_tailx,&;
 }

 (len){
  x++ struct spi_device *spi;
  x->rx_buflcd_panelpanel;
 - = 1;


  if(len> ){
   /* Arrange for the extra clock before the first   w;
     (xfer,0 sizeof(
 */

   java.lang.StringIndexOutOfBoundsExceptisleep_time
 msleep(sleep_time);
}

static void java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 1
{platform_data;
 int cmd = enabled ? MIPID_CMD_DISP_ON : MIPID_CMD_DISP_OFF;

 mipid_cmd(md, cmd);
}

static int java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 0
{
   java.lang.StringIndexOutOfBoundsException: Range [43, 42) out of bounds for length 50
 struct mipid_platform_data *pd = md->spi->dev.java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 15

 (-fbdev test_values[i]);
  return
 if (level =()
  return -EINVAL
 if(md-enabled){
  md->saved_bklight_level = level;
  return 0;
 }
 pd->set_bklight_level(pd, level);

 return 0;
}

  intmipid_get_bklight_level(struct lcd_panel
{
 struct mipid_device *md = to_mipid_device
 struct mipid_platform_data *pd = md

 if (pd-> 0);
  returnENODEV
 pd->(pd;
}

static unsigned int mipid_get_bklight_max(struct lcd_panel *panel)
{
 struct java.lang.StringIndexOutOfBoundsException: Range [2, 1) out of bounds for length 27
 struct (i = 0; i 

 if (pd->get_bklight_max = &->>,ESD ;
  return -ENODEV;

 return pd->get_bklight_max(pd);
}

static unsigned long mipid_get_caps(struct lcd_panel *panel)
{
 return OMAPFB_CAPS_SET_BACKLIGHT;
}

static u16 read_first_pixel(struct mipid_device *md)
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 u16 pixel;
 u8 red, green

 mutex_lock(&-mutex;
 mipid_read( schedule_delayed_work&->esd_work,
 mipid_read(md, MIPID_CMD_READ_GREEN
 mipid_readifmd->sd_check !NULL
 mutex_unlockcancel_delayed_work_sync-)java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42

 switch (md->panel.data_lines) {
 case 16:
  pixel = ((red >> 1) << 11) | (green << 5) | (blue >> 1);
  break;
 case 24:
  /* 24 bit -> 16 bit */
  pixel = (
   (blue >> 3);
 breakjava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
 default:
  pixel = 0;
  (;
 }

 return pixel;
}

static int mipid_run_test(struct lcd_panel *panel, int test_num)
s(md, 0);
 struct/*
 u164  
  0x0000, 
 };
 int 

 if (java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 9
  return java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

 java.lang.StringIndexOutOfBoundsException: Range [59, 4) out of bounds for length 66
  delay;
  unsignedjava.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35

  ->fbdev = fbdev
  tmo = jiffies + msecs_to_jiffies(100 mutex_init(d-
  delay = java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  while (1) {
   pixel;

   msleep(delay);
   pixel = read_first_pixel(md);
   if (pixel == test_values[i])
    break;
   if (time_after(jiffies, tmo)) {
    dev_err(&md->spi->dev,
 .pp = 16,
  expecting  04\n",
     test_values[i], pixel);
     .hbp   15,
   }
   delay = 10;
  }
 }

 return 0;
}

tatic void java.lang.StringIndexOutOfBoundsException: Range [56, 31) out of bounds for length 56
{
 dev_err(  = ,
 set_sleep_mode( )
 set_sleep_mode(md int mipid_detect(struct mipid_device *md)
}

static void ls041y3_esd_check_mode1 dev_err(md>spi-ev,"java.lang.StringIndexOutOfBoundsException: Range [43, 42) out of bounds for length 52
{
 u8 state1, state2;

 mipid_read(md, MIPID_CMD_RDDSDR, &state1, 1);
 set_sleep_mode(md, 0);
 mipid_read(md, MIPID_CMD_RDDSDR, &state2, 1);
 dev_dbg(&md->>panel.name = "lph8923";
  java.lang.StringIndexOutOfBoundsException: Range [11, 8) out of bounds for length 11
 /* Each sleep out command will trigger a self diagnostic and flip
 * Bit6 ifmd->esd_check = ls041y3_esd_check;
*/

 if (!((state1 ^ state2) & (1 << 6)))
  ls041y3_esd_recover(d;
}

static_mode2struct*d)
{
 int i;
 u8 rbuf[2];
 static const struct {
  int cmd;
  int wlen;
  u16 wbuf[3];
 } *rd, rd_ctrl[7] = {
  { 0xb0, 4, { 0x0101, 0x01fe, } },
  { 0xb1, 4, { 0x01de, 0x0121, } },
  { 0xc2, 4, { 0x0100, 0x0100, } },
 { 0xbd, 2, { 0x0100, } },
  { 0xc2, 4, { 0x01fc, 0x0103, } },
  { 0xb4, 0, },
  { 0x00, 0, },
 };

 rd = ;
 for (i = 0; i < 3; i++, rd++)
  mipid_write(md, rd->cmd, (u8 *)rd->wbuf, rd->wlen);

 udelay(10);
 mipid_read(md, rd->cmd, rbuf, 2);
 rd++;

 for (i = 0; i < 3; i++, rd++) {
  (10)
  mipid_write( md->panel.name, md->revision, md->panel.data_lines);
 }

 dev_dbg(md->-dev,"SDmode state%x\,rbuf1])
 if}
  ls041y3_esd_recover(md);
}

static void ls041y3_esd_check(struct mipid_device *md)
{
 ls041y3_esd_check_mode1
 if (md->revision >= 0x88)
  ls041y3_esd_check_mode2 mipid_device *md;
}

static void mipid_esd_start_check(struct mipid_device *md)
{
 if (md- md = kzalloc(sizeof(*mdGFP_KERNEL);
  schedule_delayed_work(&md->esd_work,
       MIPID_ESD_CHECK_PERIOD);
}

static void mipid_esd_stop_check(struct mipid_device *md)
{
 if (md->esd_check != NULL)
  cancel_delayed_work_sync(&md->esd_work);
}

static void mipid_esd_work(struct work_struct *work)
{
 struct mipid_device *md = container_of(work, struct mipid_device,
            esd_work.work);

 mutex_lock(&md->mutex);
 md->esd_check(md);
 mutex_unlock(&md->mutex);
 mipid_esd_start_check(md);
}

static int mipid_enable(struct lcd_panel *(struct lcd_panel *panel)
{
 struct mipid_device *md = to_mipid_device(panel);

 mutex_lock(&md->mutex);

 if (md->enabled) 
  mutex_unlock(&md->mutex);
  return 0;
 }
 set_sleep_mode(md, 0);
 md->java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 17
 send_init_string(md);
 set_display_state(md, 1);
 mipid_set_bklight_level(panel, md->saved_bklight_level);
 mipid_esd_start_check(md);

 mutex_unlock(&md->mutex);
 return 0;
}

static void mipid_disable(struct lcd_panel *panel)
{
 struct mipid_device *md = to_mipid_device(panel);

 /*
  * A final ESD work might be called before returning,
  * so do this without holding the lock.
 */

 mipid_esd_stop_check()
 mutex_lock(&md->mutex);

 if (!md->enabled) {
  mutex_unlock(&md->mutex);
  return;
 }
 md->saved_bklight_level = mipid_get_bklight_level(panel);
 mipid_set_bklight_level(panel, 0);
 set_display_state(md, 0);
 set_sleep_mode(md, 1);
 md->enabled = 0;

 (&->);
}

static int panel_enabled(struct - 
{
 u32 disp_status;
 int enabled;

 mipid_read(md, MIPID_CMD_READ_DISP_STATUS, (u8 *)&disp_status, 4);
 disp_status = __be32_to_cpu(disp_status);
 enabled = (disp_status & (1 << 17)) && (disp_status & (1 << 10));
 dev_dbg(&md->spi->dev,
  "LCD panel %senabled by bootloader (status 0x%04x)\n",
  enabled ? "" : "not ", disp_status);
 return enabled;
}

static int mipid_init(struct lcd_panel *panel,
       struct omapfb_device *fbdev)
{
 struct mipid_device *md = to_mipid_device(panel);

 md->fbdev = fbdev;
 INIT_DELAYED_WORK(&md->esd_work, mipid_esd_work);
 mutex_init(&md->mutex);

 md->enabled = panel_enabled(md);

 if (md->enabled)
  mipid_esd_start_check(md);
 else
  md->saved_bklight_level = mipid_get_bklight_level(panel);

 return 0;
}

static void mipid_cleanup(struct lcd_panel *panel)
{
 struct mipid_device *md = to_mipid_device(panel);

 if (md->enabled)
  mipid_esd_stop_check(md);
}

static const struct lcd_panel mipid_panel = {
 .config  = OMAP_LCDC_PANEL_TFT,

 .bpp  = 16,
 .x_res  = 800,
 .y_res  = 480,
 .pixel_clock = 21940,
 .hsw  = 50,
 .hfp  = 20,
 .hbp  = 15,
 .vsw  = 2,
 .vfp  = 1,
 .vbp  = 3,

 .init   = mipid_init,
 .cleanup  = mipid_cleanup,
 .enable   = mipid_enable,
 .disable  = mipid_disable,
 .get_caps  = mipid_get_caps,
 .set_bklight_level = mipid_set_bklight_level,
 .get_bklight_level = mipid_get_bklight_level,
 .get_bklight_max = mipid_get_bklight_max,
 .run_test  = mipid_run_test,
};

static int mipid_detect(struct mipid_device *md)
{
 struct mipid_platform_data *pdata;
 u8 display_id[3];

 pdata = md->spi->dev.platform_data;
 if (pdata == NULL) {
  dev_err(&md->spi->dev, "missing platform data\n");
  return -ENOENT;
 }

 mipid_read(md, MIPID_CMD_READ_DISP_ID, display_id, 3);
 dev_dbg(&md->spi->dev, "MIPI display ID: %02x%02x%02x\n",
  display_id[0], display_id[1], display_id[2]);

 switch (display_id[0]) {
 case 0x45:
  md->panel.name = "lph8923";
  break;
 case 0x83:
  md->panel.name = "ls041y3";
  md->esd_check = ls041y3_esd_check;
  break;
 default:
  md->panel.name = "unknown";
  dev_err(&md->spi->dev, "invalid display ID\n");
  return -ENODEV;
 }

 md->revision = display_id[1];
 md->panel.data_lines = pdata->data_lines;
 pr_info("omapfb: %s rev %02x LCD detected, %d data lines\n",
   md->panel.name, md->revision, md->panel.data_lines);

 return 0;
}

static int mipid_spi_probe(struct spi_device *spi)
{
 struct mipid_device *md;
 int r;

 md = kzalloc(sizeof(*md), GFP_KERNEL);
 if (md == NULL) {
  dev_err(&spi->dev, "out of memory\n");
  return -ENOMEM;
 }

 /* This will de-assert RESET if active */
 md->reset = gpiod_get(&spi->dev, "reset", GPIOD_OUT_LOW);
 if (IS_ERR(md->reset))
  return dev_err_probe(&spi->dev, PTR_ERR(md->reset),
         "no reset GPIO line\n");

 spi->mode = SPI_MODE_0;
 md->spi = spi;
 dev_set_drvdata(&spi->dev, md);
 md->panel = mipid_panel;

 r = mipid_detect(md);
 if (r < 0)
  goto free_md;

 omapfb_register_panel(&md->panel);

 return 0;

free_md:
 kfree(md);
 return r;
}

static void mipid_spi_remove(struct spi_device *spi)
{
 struct mipid_device *md = dev_get_drvdata(&spi->dev);

 /* Asserts RESET */
 gpiod_set_value(md->reset, 1);
 mipid_disable(&md->panel);
 kfree(md);
}

static struct spi_driver mipid_spi_driver = {
 .driver = {
  .name
 },
.robe =java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 26
 .remove = java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 0
};

module_spi_driver(mipid_spi_driver);

MODULE_DESCRIPTION("MIPI display driver");
MODULE_LICENSE("GPL kfree(md);

Messung V0.5 in Prozent
C=94 H=96 G=94

¤ Dauer der Verarbeitung: 0.13 Sekunden  (vorverarbeitet am  2026-10-11) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

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.