Lines Matching +full:default +full:- +full:brightness

1 // SPDX-License-Identifier: GPL-2.0-only
4 * Based on code and know-how from the Samsung GT-S7710
40 gpiod_set_value_cansleep(ktd253->gpiod, 1); in ktd253_backlight_set_max_ratio()
63 gpiod_set_value(ktd253->gpiod, 0); in ktd253_backlight_stepdown()
65 gpiod_set_value(ktd253->gpiod, 1); in ktd253_backlight_stepdown()
66 ns = ktime_get_ns() - ns; in ktd253_backlight_stepdown()
68 dev_err(ktd253->dev, "PCM on backlight took too long (%llu ns)\n", ns); in ktd253_backlight_stepdown()
69 return -EAGAIN; in ktd253_backlight_stepdown()
78 int brightness = backlight_get_brightness(bl); in ktd253_backlight_update_status() local
80 u16 current_ratio = ktd253->ratio; in ktd253_backlight_update_status()
83 dev_dbg(ktd253->dev, "new brightness/ratio: %d/32\n", brightness); in ktd253_backlight_update_status()
85 target_ratio = brightness; in ktd253_backlight_update_status()
92 gpiod_set_value_cansleep(ktd253->gpiod, 0); in ktd253_backlight_update_status()
98 ktd253->ratio = 0; in ktd253_backlight_update_status()
114 if (ret == -EAGAIN) { in ktd253_backlight_update_status()
120 gpiod_set_value_cansleep(ktd253->gpiod, 0); in ktd253_backlight_update_status()
128 current_ratio--; in ktd253_backlight_update_status()
131 ktd253->ratio = current_ratio; in ktd253_backlight_update_status()
133 dev_dbg(ktd253->dev, "new ratio set to %d/32\n", target_ratio); in ktd253_backlight_update_status()
145 struct device *dev = &pdev->dev; in ktd253_backlight_probe()
149 u32 brightness; in ktd253_backlight_probe() local
154 return -ENOMEM; in ktd253_backlight_probe()
155 ktd253->dev = dev; in ktd253_backlight_probe()
157 ret = device_property_read_u32(dev, "max-brightness", &max_brightness); in ktd253_backlight_probe()
161 /* Clamp brightness to hardware max */ in ktd253_backlight_probe()
162 dev_err(dev, "illegal max brightness specified\n"); in ktd253_backlight_probe()
166 ret = device_property_read_u32(dev, "default-brightness", &brightness); in ktd253_backlight_probe()
168 brightness = KTD253_DEFAULT_RATIO; in ktd253_backlight_probe()
169 if (brightness > max_brightness) { in ktd253_backlight_probe()
170 /* Clamp default brightness to max brightness */ in ktd253_backlight_probe()
171 dev_err(dev, "default brightness exceeds max brightness\n"); in ktd253_backlight_probe()
172 brightness = max_brightness; in ktd253_backlight_probe()
175 ktd253->gpiod = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW); in ktd253_backlight_probe()
176 if (IS_ERR(ktd253->gpiod)) in ktd253_backlight_probe()
177 return dev_err_probe(dev, PTR_ERR(ktd253->gpiod), in ktd253_backlight_probe()
179 gpiod_set_consumer_name(ktd253->gpiod, dev_name(dev)); in ktd253_backlight_probe()
189 bl->props.max_brightness = max_brightness; in ktd253_backlight_probe()
190 /* When we just enable the GPIO line we set max brightness */ in ktd253_backlight_probe()
191 if (brightness) { in ktd253_backlight_probe()
192 bl->props.brightness = brightness; in ktd253_backlight_probe()
193 bl->props.power = FB_BLANK_UNBLANK; in ktd253_backlight_probe()
195 bl->props.brightness = 0; in ktd253_backlight_probe()
196 bl->props.power = FB_BLANK_POWERDOWN; in ktd253_backlight_probe()
199 ktd253->bl = bl; in ktd253_backlight_probe()
215 .name = "ktd253-backlight",
225 MODULE_ALIAS("platform:ktd253-backlight");