root/drivers/gpu/drm/shmobile/shmob_drm_backlight.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. shmob_drm_backlight_update
  2. shmob_drm_backlight_get_brightness
  3. shmob_drm_backlight_dpms
  4. shmob_drm_backlight_init
  5. shmob_drm_backlight_exit

   1 // SPDX-License-Identifier: GPL-2.0+
   2 /*
   3  * shmob_drm_backlight.c  --  SH Mobile DRM Backlight
   4  *
   5  * Copyright (C) 2012 Renesas Electronics Corporation
   6  *
   7  * Laurent Pinchart (laurent.pinchart@ideasonboard.com)
   8  */
   9 
  10 #include <linux/backlight.h>
  11 
  12 #include "shmob_drm_backlight.h"
  13 #include "shmob_drm_crtc.h"
  14 #include "shmob_drm_drv.h"
  15 
  16 static int shmob_drm_backlight_update(struct backlight_device *bdev)
  17 {
  18         struct shmob_drm_connector *scon = bl_get_data(bdev);
  19         struct shmob_drm_device *sdev = scon->connector.dev->dev_private;
  20         const struct shmob_drm_backlight_data *bdata = &sdev->pdata->backlight;
  21         int brightness = bdev->props.brightness;
  22 
  23         if (bdev->props.power != FB_BLANK_UNBLANK ||
  24             bdev->props.state & BL_CORE_SUSPENDED)
  25                 brightness = 0;
  26 
  27         return bdata->set_brightness(brightness);
  28 }
  29 
  30 static int shmob_drm_backlight_get_brightness(struct backlight_device *bdev)
  31 {
  32         struct shmob_drm_connector *scon = bl_get_data(bdev);
  33         struct shmob_drm_device *sdev = scon->connector.dev->dev_private;
  34         const struct shmob_drm_backlight_data *bdata = &sdev->pdata->backlight;
  35 
  36         return bdata->get_brightness();
  37 }
  38 
  39 static const struct backlight_ops shmob_drm_backlight_ops = {
  40         .options        = BL_CORE_SUSPENDRESUME,
  41         .update_status  = shmob_drm_backlight_update,
  42         .get_brightness = shmob_drm_backlight_get_brightness,
  43 };
  44 
  45 void shmob_drm_backlight_dpms(struct shmob_drm_connector *scon, int mode)
  46 {
  47         if (scon->backlight == NULL)
  48                 return;
  49 
  50         scon->backlight->props.power = mode == DRM_MODE_DPMS_ON
  51                                      ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN;
  52         backlight_update_status(scon->backlight);
  53 }
  54 
  55 int shmob_drm_backlight_init(struct shmob_drm_connector *scon)
  56 {
  57         struct shmob_drm_device *sdev = scon->connector.dev->dev_private;
  58         const struct shmob_drm_backlight_data *bdata = &sdev->pdata->backlight;
  59         struct drm_connector *connector = &scon->connector;
  60         struct drm_device *dev = connector->dev;
  61         struct backlight_device *backlight;
  62 
  63         if (!bdata->max_brightness)
  64                 return 0;
  65 
  66         backlight = backlight_device_register(bdata->name, dev->dev, scon,
  67                                               &shmob_drm_backlight_ops, NULL);
  68         if (IS_ERR(backlight)) {
  69                 dev_err(dev->dev, "unable to register backlight device: %ld\n",
  70                         PTR_ERR(backlight));
  71                 return PTR_ERR(backlight);
  72         }
  73 
  74         backlight->props.max_brightness = bdata->max_brightness;
  75         backlight->props.brightness = bdata->max_brightness;
  76         backlight->props.power = FB_BLANK_POWERDOWN;
  77         backlight_update_status(backlight);
  78 
  79         scon->backlight = backlight;
  80         return 0;
  81 }
  82 
  83 void shmob_drm_backlight_exit(struct shmob_drm_connector *scon)
  84 {
  85         backlight_device_unregister(scon->backlight);
  86 }

/* [<][>][^][v][top][bottom][index][help] */