On Wed, 27 Jan 2021 14:47:04 +0100 Geert Uytterhoeven <geert@xxxxxxxxxxxxxx> wrote: > Hi Carlis, > > On Wed, Jan 27, 2021 at 2:03 PM Carlis <zhangxuezhi3@xxxxxxxxx> wrote: > > From: zhangxuezhi <zhangxuezhi1@xxxxxxxxxx> > > > > For st7789v ic,add tearing signal detect to avoid screen tearing > > > > Signed-off-by: zhangxuezhi <zhangxuezhi1@xxxxxxxxxx> > > --- > > v9: change pr_* to dev_* > > Thanks for the update! > > > --- a/drivers/staging/fbtft/fb_st7789v.c > > +++ b/drivers/staging/fbtft/fb_st7789v.c > > @@ -9,9 +9,12 @@ > > #include <linux/delay.h> > > #include <linux/init.h> > > #include <linux/kernel.h> > > +#include <linux/mutex.h> > > +#include <linux/interrupt.h> > > +#include <linux/completion.h> > > #include <linux/module.h> > > #include <video/mipi_display.h> > > - > > +#include <linux/gpio/consumer.h> > > #include "fbtft.h" > > > > #define DRVNAME "fb_st7789v" > > @@ -66,6 +69,32 @@ enum st7789v_command { > > #define MADCTL_MX BIT(6) /* bitmask for column address order */ > > #define MADCTL_MY BIT(7) /* bitmask for page address order */ > > > > +#define SPI_PANEL_TE_TIMEOUT 400 > > +static struct mutex te_mutex;/*mutex for tearing line*/ > > +static struct completion spi_panel_te; > > + > > +static irqreturn_t spi_panel_te_handler(int irq, void *data) > > +{ > > + complete(&spi_panel_te); > > + return IRQ_HANDLED; > > +} > > + > > +static void set_spi_panel_te_irq_status(struct fbtft_par *par, > > bool enable) +{ > > + static int te_irq_count; > > + > > + mutex_lock(&te_mutex); > > + > > + if (enable) { > > + if (++te_irq_count == 1) > > + enable_irq(gpiod_to_irq(par->gpio.te)); > > + } else { > > + if (--te_irq_count == 0) > > + disable_irq(gpiod_to_irq(par->gpio.te)); > > + } > > + mutex_unlock(&te_mutex); > > +} > > + > > /** > > * init_display() - initialize the display controller > > * > > @@ -82,6 +111,33 @@ enum st7789v_command { > > */ > > static int init_display(struct fbtft_par *par) > > { > > + int rc; > > + struct device *dev = par->info->device; > > + > > + par->gpio.te = devm_gpiod_get_index_optional(dev, "te", 0, > > GPIOD_IN); > > + if (IS_ERR(par->gpio.te)) { > > + rc = PTR_ERR(par->gpio.te); > > + dev_err(par->info->device, "Failed to request te > > gpio: %d\n", rc); > > This also prints an error in case of -EPROBE_DEFER. > dev_err_probe()? > > > + return rc; > > + } > > + if (par->gpio.te) { > > + init_completion(&spi_panel_te); > > + mutex_init(&te_mutex); > > + rc = devm_request_irq(dev, > > + gpiod_to_irq(par->gpio.te), > > + spi_panel_te_handler, > > IRQF_TRIGGER_RISING, > > + "TE_GPIO", par); > > + if (rc) { > > + dev_err(par->info->device, "TE request_irq > > failed.\n"); > > + devm_gpiod_put(dev, par->gpio.te); > > No need to call devm_gpiod_put() here, as it's managed automatically. > > Gr{oetje,eeting}s, > > Geert > hi,i will fix in patch v11 regards zhangxuezhi1 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel