• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1  /*
2  * Copyright (C) 2019 Allwinnertech Co.Ltd
3  * Authors: zhengwanyu
4  *
5  * This program is free software; you can redistribute  it and/or modify it
6  * under  the terms of  the GNU General  Public License as published by the
7  * Free Software Foundation;  either version 2 of the  License, or (at your
8  * option) any later version.
9  *
10  */
11 #include "../sunxi_drm_connector.h"
12 #ifndef _SUNXI_BACKLIGHT_H_
13 #define _SUNXI_BACKLIGHT_H_
14 
15 #include <linux/pwm.h>
16 #include <linux/backlight.h>
17 
18 #define	BL_NUM_MAX	2
19 
20 struct pwm_config {
21 	unsigned int lcd_pwm_ch;
22 	unsigned int lcd_pwm_freq;
23 	unsigned int lcd_pwm_pol;
24 };
25 
26 struct backlight_config {
27 	unsigned char use_bl_en;
28 	struct disp_gpio_info bl_en_gpio;
29 	char bl_en_power[32];
30 
31 	unsigned char use_pwm;
32 	unsigned long long bright;
33 	struct pwm_config pwm;
34 };
35 
36 struct pwm_info {
37 #if IS_ENABLED(CONFIG_AW_PWM) || IS_ENABLED(CONFIG_PWM_SUNXI_NEW) || IS_ENABLED(CONFIG_PWM_SUNXI_GROUP)
38 	struct pwm_device *pwm_dev;
39 #endif
40 	u32 channel;
41 	u32 polarity;
42 	u32 period_ns;
43 	u32 duty_ns;
44 	u32 enabled;
45 };
46 
47 struct sunxi_lcd_backlight {
48 	struct device *dev;
49 	/*CONFIG_BACKLIGHT_CLASS_DEVICE*/
50 	struct backlight_device *bl_dev;
51 	int lcd_id;
52 
53 	unsigned char use_bl_en;
54 	struct disp_gpio_info bl_en_gpio;
55 	int bl_gpio_hdl;
56 	char bl_en_power[32];
57 	/*indicate if this backlight is enable,
58 	*and how many time it enable
59 	*/
60 	unsigned char bl_en_count;
61 
62 	unsigned char use_pwm;
63 	unsigned int bright_curve_tbl[256];
64 	unsigned long long bright;
65 	struct pwm_info pwm_info;
66 
67 	unsigned int dimming;
68 
69 	/* backlight registers and fields in struct intel_panel */
70 	struct mutex backlight_lock;
71 };
72 
73 ssize_t sunxi_backlight_info(char *buf);
74 
75 int sunxi_backlight_init(int lcd_id, struct backlight_config *config,
76 					unsigned int *bl_curve_tbl);
77 void sunxi_backlight_remove(int lcd_id);
78 
79 int sunxi_backlight_drv_init(void);
80 int sunxi_backlight_drv_exit(void);
81 
82 int sunxi_backlight_pwm_enable(unsigned int lcd_id);
83 int sunxi_backlight_pwm_disable(unsigned int lcd_id);
84 int sunxi_backlight_enable(unsigned int lcd_id);
85 int sunxi_backlight_disable(unsigned int lcd_id);
86 
87 int sunxi_backlight_device_register(struct device *device,
88 		unsigned int lcd_id);
89 void sunxi_backlight_device_unregister(unsigned int lcd_id);
90 #endif
91