backlight.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Backlight Lowlevel Control Abstraction
  4. *
  5. * Copyright (C) 2003,2004 Hewlett-Packard Company
  6. *
  7. */
  8. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  9. #include <linux/module.h>
  10. #include <linux/init.h>
  11. #include <linux/device.h>
  12. #include <linux/backlight.h>
  13. #include <linux/notifier.h>
  14. #include <linux/ctype.h>
  15. #include <linux/err.h>
  16. #include <linux/slab.h>
  17. #include <linux/of.h>
  18. #ifdef CONFIG_PMAC_BACKLIGHT
  19. #include <asm/backlight.h>
  20. #endif
  21. /**
  22. * DOC: overview
  23. *
  24. * The backlight core supports implementing backlight drivers.
  25. *
  26. * A backlight driver registers a driver using
  27. * devm_backlight_device_register(). The properties of the backlight
  28. * driver such as type and max_brightness must be specified.
  29. * When the core detect changes in for example brightness or power state
  30. * the update_status() operation is called. The backlight driver shall
  31. * implement this operation and use it to adjust backlight.
  32. *
  33. * Several sysfs attributes are provided by the backlight core::
  34. *
  35. * - brightness R/W, set the requested brightness level
  36. * - actual_brightness RO, the brightness level used by the HW
  37. * - max_brightness RO, the maximum brightness level supported
  38. *
  39. * See Documentation/ABI/stable/sysfs-class-backlight for the full list.
  40. *
  41. * The backlight can be adjusted using the sysfs interface, and
  42. * the backlight driver may also support adjusting backlight using
  43. * a hot-key or some other platform or firmware specific way.
  44. *
  45. * The driver must implement the get_brightness() operation if
  46. * the HW do not support all the levels that can be specified in
  47. * brightness, thus providing user-space access to the actual level
  48. * via the actual_brightness attribute.
  49. *
  50. * When the backlight changes this is reported to user-space using
  51. * an uevent connected to the actual_brightness attribute.
  52. * When brightness is set by platform specific means, for example
  53. * a hot-key to adjust backlight, the driver must notify the backlight
  54. * core that brightness has changed using backlight_force_update().
  55. *
  56. * Display drives can control the backlight device's status using
  57. * backlight_notify_blank() and backlight_notify_blank_all(). If this
  58. * results in a change in the backlight state the functions call the
  59. * update_status() operation.
  60. */
  61. static struct list_head backlight_dev_list;
  62. static struct mutex backlight_dev_list_mutex;
  63. static const char *const backlight_types[] = {
  64. [BACKLIGHT_RAW] = "raw",
  65. [BACKLIGHT_PLATFORM] = "platform",
  66. [BACKLIGHT_FIRMWARE] = "firmware",
  67. };
  68. static const char *const backlight_scale_types[] = {
  69. [BACKLIGHT_SCALE_UNKNOWN] = "unknown",
  70. [BACKLIGHT_SCALE_LINEAR] = "linear",
  71. [BACKLIGHT_SCALE_NON_LINEAR] = "non-linear",
  72. };
  73. void backlight_notify_blank(struct backlight_device *bd, struct device *display_dev,
  74. bool fb_on, bool prev_fb_on)
  75. {
  76. guard(mutex)(&bd->ops_lock);
  77. if (!bd->ops)
  78. return;
  79. if (bd->ops->controls_device && !bd->ops->controls_device(bd, display_dev))
  80. return;
  81. if (fb_on && (!prev_fb_on || !bd->use_count)) {
  82. if (!bd->use_count++) {
  83. bd->props.state &= ~BL_CORE_FBBLANK;
  84. backlight_update_status(bd);
  85. }
  86. } else if (!fb_on && prev_fb_on && bd->use_count) {
  87. if (!(--bd->use_count)) {
  88. bd->props.state |= BL_CORE_FBBLANK;
  89. backlight_update_status(bd);
  90. }
  91. }
  92. }
  93. EXPORT_SYMBOL(backlight_notify_blank);
  94. void backlight_notify_blank_all(struct device *display_dev, bool fb_on, bool prev_fb_on)
  95. {
  96. struct backlight_device *bd;
  97. guard(mutex)(&backlight_dev_list_mutex);
  98. list_for_each_entry(bd, &backlight_dev_list, entry)
  99. backlight_notify_blank(bd, display_dev, fb_on, prev_fb_on);
  100. }
  101. EXPORT_SYMBOL(backlight_notify_blank_all);
  102. static void backlight_generate_event(struct backlight_device *bd,
  103. enum backlight_update_reason reason)
  104. {
  105. char *envp[2];
  106. switch (reason) {
  107. case BACKLIGHT_UPDATE_SYSFS:
  108. envp[0] = "SOURCE=sysfs";
  109. break;
  110. case BACKLIGHT_UPDATE_HOTKEY:
  111. envp[0] = "SOURCE=hotkey";
  112. break;
  113. default:
  114. envp[0] = "SOURCE=unknown";
  115. break;
  116. }
  117. envp[1] = NULL;
  118. kobject_uevent_env(&bd->dev.kobj, KOBJ_CHANGE, envp);
  119. sysfs_notify(&bd->dev.kobj, NULL, "actual_brightness");
  120. }
  121. static ssize_t bl_power_show(struct device *dev, struct device_attribute *attr,
  122. char *buf)
  123. {
  124. struct backlight_device *bd = to_backlight_device(dev);
  125. return sprintf(buf, "%d\n", bd->props.power);
  126. }
  127. static ssize_t bl_power_store(struct device *dev, struct device_attribute *attr,
  128. const char *buf, size_t count)
  129. {
  130. int rc;
  131. struct backlight_device *bd = to_backlight_device(dev);
  132. unsigned long power, old_power;
  133. rc = kstrtoul(buf, 0, &power);
  134. if (rc)
  135. return rc;
  136. rc = -ENXIO;
  137. mutex_lock(&bd->ops_lock);
  138. if (bd->ops) {
  139. pr_debug("set power to %lu\n", power);
  140. if (bd->props.power != power) {
  141. old_power = bd->props.power;
  142. bd->props.power = power;
  143. rc = backlight_update_status(bd);
  144. if (rc)
  145. bd->props.power = old_power;
  146. else
  147. rc = count;
  148. } else {
  149. rc = count;
  150. }
  151. }
  152. mutex_unlock(&bd->ops_lock);
  153. return rc;
  154. }
  155. static DEVICE_ATTR_RW(bl_power);
  156. static ssize_t brightness_show(struct device *dev,
  157. struct device_attribute *attr, char *buf)
  158. {
  159. struct backlight_device *bd = to_backlight_device(dev);
  160. return sprintf(buf, "%d\n", bd->props.brightness);
  161. }
  162. int backlight_device_set_brightness(struct backlight_device *bd,
  163. unsigned long brightness)
  164. {
  165. int rc = -ENXIO;
  166. mutex_lock(&bd->ops_lock);
  167. if (bd->ops) {
  168. if (brightness > bd->props.max_brightness)
  169. rc = -EINVAL;
  170. else {
  171. pr_debug("set brightness to %lu\n", brightness);
  172. bd->props.brightness = brightness;
  173. rc = backlight_update_status(bd);
  174. }
  175. }
  176. mutex_unlock(&bd->ops_lock);
  177. backlight_generate_event(bd, BACKLIGHT_UPDATE_SYSFS);
  178. return rc;
  179. }
  180. EXPORT_SYMBOL(backlight_device_set_brightness);
  181. static ssize_t brightness_store(struct device *dev,
  182. struct device_attribute *attr, const char *buf, size_t count)
  183. {
  184. int rc;
  185. struct backlight_device *bd = to_backlight_device(dev);
  186. unsigned long brightness;
  187. rc = kstrtoul(buf, 0, &brightness);
  188. if (rc)
  189. return rc;
  190. rc = backlight_device_set_brightness(bd, brightness);
  191. return rc ? rc : count;
  192. }
  193. static DEVICE_ATTR_RW(brightness);
  194. static ssize_t type_show(struct device *dev, struct device_attribute *attr,
  195. char *buf)
  196. {
  197. struct backlight_device *bd = to_backlight_device(dev);
  198. return sprintf(buf, "%s\n", backlight_types[bd->props.type]);
  199. }
  200. static DEVICE_ATTR_RO(type);
  201. static ssize_t max_brightness_show(struct device *dev,
  202. struct device_attribute *attr, char *buf)
  203. {
  204. struct backlight_device *bd = to_backlight_device(dev);
  205. return sprintf(buf, "%d\n", bd->props.max_brightness);
  206. }
  207. static DEVICE_ATTR_RO(max_brightness);
  208. static ssize_t actual_brightness_show(struct device *dev,
  209. struct device_attribute *attr, char *buf)
  210. {
  211. int rc = -ENXIO;
  212. struct backlight_device *bd = to_backlight_device(dev);
  213. mutex_lock(&bd->ops_lock);
  214. if (bd->ops && bd->ops->get_brightness) {
  215. rc = bd->ops->get_brightness(bd);
  216. if (rc >= 0)
  217. rc = sprintf(buf, "%d\n", rc);
  218. } else {
  219. rc = sprintf(buf, "%d\n", bd->props.brightness);
  220. }
  221. mutex_unlock(&bd->ops_lock);
  222. return rc;
  223. }
  224. static DEVICE_ATTR_RO(actual_brightness);
  225. static ssize_t scale_show(struct device *dev,
  226. struct device_attribute *attr, char *buf)
  227. {
  228. struct backlight_device *bd = to_backlight_device(dev);
  229. if (WARN_ON(bd->props.scale > BACKLIGHT_SCALE_NON_LINEAR))
  230. return sprintf(buf, "unknown\n");
  231. return sprintf(buf, "%s\n", backlight_scale_types[bd->props.scale]);
  232. }
  233. static DEVICE_ATTR_RO(scale);
  234. #ifdef CONFIG_PM_SLEEP
  235. static int backlight_suspend(struct device *dev)
  236. {
  237. struct backlight_device *bd = to_backlight_device(dev);
  238. mutex_lock(&bd->ops_lock);
  239. if (bd->ops && bd->ops->options & BL_CORE_SUSPENDRESUME) {
  240. bd->props.state |= BL_CORE_SUSPENDED;
  241. backlight_update_status(bd);
  242. }
  243. mutex_unlock(&bd->ops_lock);
  244. return 0;
  245. }
  246. static int backlight_resume(struct device *dev)
  247. {
  248. struct backlight_device *bd = to_backlight_device(dev);
  249. mutex_lock(&bd->ops_lock);
  250. if (bd->ops && bd->ops->options & BL_CORE_SUSPENDRESUME) {
  251. bd->props.state &= ~BL_CORE_SUSPENDED;
  252. backlight_update_status(bd);
  253. }
  254. mutex_unlock(&bd->ops_lock);
  255. return 0;
  256. }
  257. #endif
  258. static SIMPLE_DEV_PM_OPS(backlight_class_dev_pm_ops, backlight_suspend,
  259. backlight_resume);
  260. static void bl_device_release(struct device *dev)
  261. {
  262. struct backlight_device *bd = to_backlight_device(dev);
  263. kfree(bd);
  264. }
  265. static struct attribute *bl_device_attrs[] = {
  266. &dev_attr_bl_power.attr,
  267. &dev_attr_brightness.attr,
  268. &dev_attr_actual_brightness.attr,
  269. &dev_attr_max_brightness.attr,
  270. &dev_attr_scale.attr,
  271. &dev_attr_type.attr,
  272. NULL,
  273. };
  274. ATTRIBUTE_GROUPS(bl_device);
  275. static const struct class backlight_class = {
  276. .name = "backlight",
  277. .dev_groups = bl_device_groups,
  278. .pm = &backlight_class_dev_pm_ops,
  279. };
  280. /**
  281. * backlight_force_update - tell the backlight subsystem that hardware state
  282. * has changed
  283. * @bd: the backlight device to update
  284. * @reason: reason for update
  285. *
  286. * Updates the internal state of the backlight in response to a hardware event,
  287. * and generates an uevent to notify userspace. A backlight driver shall call
  288. * backlight_force_update() when the backlight is changed using, for example,
  289. * a hot-key. The updated brightness is read using get_brightness() and the
  290. * brightness value is reported using an uevent.
  291. */
  292. void backlight_force_update(struct backlight_device *bd,
  293. enum backlight_update_reason reason)
  294. {
  295. int brightness;
  296. mutex_lock(&bd->ops_lock);
  297. if (bd->ops && bd->ops->get_brightness) {
  298. brightness = bd->ops->get_brightness(bd);
  299. if (brightness >= 0)
  300. bd->props.brightness = brightness;
  301. else
  302. dev_err(&bd->dev,
  303. "Could not update brightness from device: %pe\n",
  304. ERR_PTR(brightness));
  305. }
  306. mutex_unlock(&bd->ops_lock);
  307. backlight_generate_event(bd, reason);
  308. }
  309. EXPORT_SYMBOL(backlight_force_update);
  310. /* deprecated - use devm_backlight_device_register() */
  311. struct backlight_device *backlight_device_register(const char *name,
  312. struct device *parent, void *devdata, const struct backlight_ops *ops,
  313. const struct backlight_properties *props)
  314. {
  315. struct backlight_device *new_bd;
  316. int rc;
  317. pr_debug("backlight_device_register: name=%s\n", name);
  318. new_bd = kzalloc_obj(struct backlight_device);
  319. if (!new_bd)
  320. return ERR_PTR(-ENOMEM);
  321. mutex_init(&new_bd->update_lock);
  322. mutex_init(&new_bd->ops_lock);
  323. new_bd->dev.class = &backlight_class;
  324. new_bd->dev.parent = parent;
  325. new_bd->dev.release = bl_device_release;
  326. dev_set_name(&new_bd->dev, "%s", name);
  327. dev_set_drvdata(&new_bd->dev, devdata);
  328. /* Set default properties */
  329. if (props) {
  330. memcpy(&new_bd->props, props,
  331. sizeof(struct backlight_properties));
  332. if (props->type <= 0 || props->type >= BACKLIGHT_TYPE_MAX) {
  333. WARN(1, "%s: invalid backlight type", name);
  334. new_bd->props.type = BACKLIGHT_RAW;
  335. }
  336. } else {
  337. new_bd->props.type = BACKLIGHT_RAW;
  338. }
  339. rc = device_register(&new_bd->dev);
  340. if (rc) {
  341. put_device(&new_bd->dev);
  342. return ERR_PTR(rc);
  343. }
  344. new_bd->ops = ops;
  345. #ifdef CONFIG_PMAC_BACKLIGHT
  346. mutex_lock(&pmac_backlight_mutex);
  347. if (!pmac_backlight)
  348. pmac_backlight = new_bd;
  349. mutex_unlock(&pmac_backlight_mutex);
  350. #endif
  351. mutex_lock(&backlight_dev_list_mutex);
  352. list_add(&new_bd->entry, &backlight_dev_list);
  353. mutex_unlock(&backlight_dev_list_mutex);
  354. return new_bd;
  355. }
  356. EXPORT_SYMBOL(backlight_device_register);
  357. /** backlight_device_get_by_type - find first backlight device of a type
  358. * @type: the type of backlight device
  359. *
  360. * Look up the first backlight device of the specified type
  361. *
  362. * RETURNS:
  363. *
  364. * Pointer to backlight device if any was found. Otherwise NULL.
  365. */
  366. struct backlight_device *backlight_device_get_by_type(enum backlight_type type)
  367. {
  368. bool found = false;
  369. struct backlight_device *bd;
  370. mutex_lock(&backlight_dev_list_mutex);
  371. list_for_each_entry(bd, &backlight_dev_list, entry) {
  372. if (bd->props.type == type) {
  373. found = true;
  374. break;
  375. }
  376. }
  377. mutex_unlock(&backlight_dev_list_mutex);
  378. return found ? bd : NULL;
  379. }
  380. EXPORT_SYMBOL(backlight_device_get_by_type);
  381. /**
  382. * backlight_device_get_by_name - Get backlight device by name
  383. * @name: Device name
  384. *
  385. * This function looks up a backlight device by its name. It obtains a reference
  386. * on the backlight device and it is the caller's responsibility to drop the
  387. * reference by calling put_device().
  388. *
  389. * Returns:
  390. * A pointer to the backlight device if found, otherwise NULL.
  391. */
  392. struct backlight_device *backlight_device_get_by_name(const char *name)
  393. {
  394. struct device *dev;
  395. dev = class_find_device_by_name(&backlight_class, name);
  396. return dev ? to_backlight_device(dev) : NULL;
  397. }
  398. EXPORT_SYMBOL(backlight_device_get_by_name);
  399. /* deprecated - use devm_backlight_device_unregister() */
  400. void backlight_device_unregister(struct backlight_device *bd)
  401. {
  402. if (!bd)
  403. return;
  404. mutex_lock(&backlight_dev_list_mutex);
  405. list_del(&bd->entry);
  406. mutex_unlock(&backlight_dev_list_mutex);
  407. #ifdef CONFIG_PMAC_BACKLIGHT
  408. mutex_lock(&pmac_backlight_mutex);
  409. if (pmac_backlight == bd)
  410. pmac_backlight = NULL;
  411. mutex_unlock(&pmac_backlight_mutex);
  412. #endif
  413. mutex_lock(&bd->ops_lock);
  414. bd->ops = NULL;
  415. mutex_unlock(&bd->ops_lock);
  416. device_unregister(&bd->dev);
  417. }
  418. EXPORT_SYMBOL(backlight_device_unregister);
  419. static void devm_backlight_device_release(struct device *dev, void *res)
  420. {
  421. struct backlight_device *backlight = *(struct backlight_device **)res;
  422. backlight_device_unregister(backlight);
  423. }
  424. static int devm_backlight_device_match(struct device *dev, void *res,
  425. void *data)
  426. {
  427. struct backlight_device **r = res;
  428. return *r == data;
  429. }
  430. /**
  431. * devm_backlight_device_register - register a new backlight device
  432. * @dev: the device to register
  433. * @name: the name of the device
  434. * @parent: a pointer to the parent device (often the same as @dev)
  435. * @devdata: an optional pointer to be stored for private driver use
  436. * @ops: the backlight operations structure
  437. * @props: the backlight properties
  438. *
  439. * Creates and registers new backlight device. When a backlight device
  440. * is registered the configuration must be specified in the @props
  441. * parameter. See description of &backlight_properties.
  442. *
  443. * RETURNS:
  444. *
  445. * struct backlight on success, or an ERR_PTR on error
  446. */
  447. struct backlight_device *devm_backlight_device_register(struct device *dev,
  448. const char *name, struct device *parent, void *devdata,
  449. const struct backlight_ops *ops,
  450. const struct backlight_properties *props)
  451. {
  452. struct backlight_device **ptr, *backlight;
  453. ptr = devres_alloc(devm_backlight_device_release, sizeof(*ptr),
  454. GFP_KERNEL);
  455. if (!ptr)
  456. return ERR_PTR(-ENOMEM);
  457. backlight = backlight_device_register(name, parent, devdata, ops,
  458. props);
  459. if (!IS_ERR(backlight)) {
  460. *ptr = backlight;
  461. devres_add(dev, ptr);
  462. } else {
  463. devres_free(ptr);
  464. }
  465. return backlight;
  466. }
  467. EXPORT_SYMBOL(devm_backlight_device_register);
  468. /**
  469. * devm_backlight_device_unregister - unregister backlight device
  470. * @dev: the device to unregister
  471. * @bd: the backlight device to unregister
  472. *
  473. * Deallocates a backlight allocated with devm_backlight_device_register().
  474. * Normally this function will not need to be called and the resource management
  475. * code will ensure that the resources are freed.
  476. */
  477. void devm_backlight_device_unregister(struct device *dev,
  478. struct backlight_device *bd)
  479. {
  480. int rc;
  481. rc = devres_release(dev, devm_backlight_device_release,
  482. devm_backlight_device_match, bd);
  483. WARN_ON(rc);
  484. }
  485. EXPORT_SYMBOL(devm_backlight_device_unregister);
  486. #ifdef CONFIG_OF
  487. static int of_parent_match(struct device *dev, const void *data)
  488. {
  489. return dev->parent && dev->parent->of_node == data;
  490. }
  491. /**
  492. * of_find_backlight_by_node() - find backlight device by device-tree node
  493. * @node: device-tree node of the backlight device
  494. *
  495. * Returns a pointer to the backlight device corresponding to the given DT
  496. * node or NULL if no such backlight device exists or if the device hasn't
  497. * been probed yet.
  498. *
  499. * This function obtains a reference on the backlight device and it is the
  500. * caller's responsibility to drop the reference by calling put_device() on
  501. * the backlight device's .dev field.
  502. */
  503. struct backlight_device *of_find_backlight_by_node(struct device_node *node)
  504. {
  505. struct device *dev;
  506. dev = class_find_device(&backlight_class, NULL, node, of_parent_match);
  507. return dev ? to_backlight_device(dev) : NULL;
  508. }
  509. EXPORT_SYMBOL(of_find_backlight_by_node);
  510. #endif
  511. static struct backlight_device *of_find_backlight(struct device *dev)
  512. {
  513. struct backlight_device *bd = NULL;
  514. struct device_node *np;
  515. if (!dev)
  516. return NULL;
  517. if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
  518. np = of_parse_phandle(dev->of_node, "backlight", 0);
  519. if (np) {
  520. bd = of_find_backlight_by_node(np);
  521. of_node_put(np);
  522. if (!bd)
  523. return ERR_PTR(-EPROBE_DEFER);
  524. }
  525. }
  526. return bd;
  527. }
  528. static void devm_backlight_release(void *data)
  529. {
  530. struct backlight_device *bd = data;
  531. put_device(&bd->dev);
  532. }
  533. /**
  534. * devm_of_find_backlight - find backlight for a device
  535. * @dev: the device
  536. *
  537. * This function looks for a property named 'backlight' on the DT node
  538. * connected to @dev and looks up the backlight device. The lookup is
  539. * device managed so the reference to the backlight device is automatically
  540. * dropped on driver detach.
  541. *
  542. * RETURNS:
  543. *
  544. * A pointer to the backlight device if found.
  545. * Error pointer -EPROBE_DEFER if the DT property is set, but no backlight
  546. * device is found. NULL if there's no backlight property.
  547. */
  548. struct backlight_device *devm_of_find_backlight(struct device *dev)
  549. {
  550. struct backlight_device *bd;
  551. int ret;
  552. bd = of_find_backlight(dev);
  553. if (IS_ERR_OR_NULL(bd))
  554. return bd;
  555. ret = devm_add_action_or_reset(dev, devm_backlight_release, bd);
  556. if (ret)
  557. return ERR_PTR(ret);
  558. return bd;
  559. }
  560. EXPORT_SYMBOL(devm_of_find_backlight);
  561. static void __exit backlight_class_exit(void)
  562. {
  563. class_unregister(&backlight_class);
  564. }
  565. static int __init backlight_class_init(void)
  566. {
  567. int ret;
  568. ret = class_register(&backlight_class);
  569. if (ret) {
  570. pr_warn("Unable to create backlight class; errno = %d\n", ret);
  571. return ret;
  572. }
  573. INIT_LIST_HEAD(&backlight_dev_list);
  574. mutex_init(&backlight_dev_list_mutex);
  575. return 0;
  576. }
  577. /*
  578. * if this is compiled into the kernel, we need to ensure that the
  579. * class is registered before users of the class try to register lcd's
  580. */
  581. postcore_initcall(backlight_class_init);
  582. module_exit(backlight_class_exit);
  583. MODULE_LICENSE("GPL");
  584. MODULE_AUTHOR("Jamey Hicks <jamey.hicks@hp.com>, Andrew Zabolotny <zap@homelink.ru>");
  585. MODULE_DESCRIPTION("Backlight Lowlevel Control Abstraction");