#include <linux/kernel.h>
#include <linux/leds.h>
#include <linux/led-class-flash.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/greybus.h>
#include <media/v4l2-flash-led-class.h>
#define NAMES_MAX …
struct gb_channel { … };
struct gb_light { … };
struct gb_lights { … };
static void gb_lights_channel_free(struct gb_channel *channel);
static struct gb_connection *get_conn_from_channel(struct gb_channel *channel)
{ … }
static struct gb_connection *get_conn_from_light(struct gb_light *light)
{ … }
static bool is_channel_flash(struct gb_channel *channel)
{ … }
static struct gb_channel *get_channel_from_cdev(struct led_classdev *cdev)
{ … }
static struct led_classdev *get_channel_cdev(struct gb_channel *channel)
{ … }
static struct gb_channel *get_channel_from_mode(struct gb_light *light,
u32 mode)
{ … }
static int __gb_lights_flash_intensity_set(struct gb_channel *channel,
u32 intensity)
{ … }
static int __gb_lights_flash_brightness_set(struct gb_channel *channel)
{ … }
static int gb_lights_color_set(struct gb_channel *channel, u32 color);
static int gb_lights_fade_set(struct gb_channel *channel);
static void led_lock(struct led_classdev *cdev)
{ … }
static void led_unlock(struct led_classdev *cdev)
{ … }
#define gb_lights_fade_attr(__dir) …
gb_lights_fade_attr(…);
gb_lights_fade_attr(…);
static ssize_t color_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static ssize_t color_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t size)
{ … }
static DEVICE_ATTR_RW(color);
static int channel_attr_groups_set(struct gb_channel *channel,
struct led_classdev *cdev)
{ … }
static int gb_lights_fade_set(struct gb_channel *channel)
{ … }
static int gb_lights_color_set(struct gb_channel *channel, u32 color)
{ … }
static int __gb_lights_led_brightness_set(struct gb_channel *channel)
{ … }
static int __gb_lights_brightness_set(struct gb_channel *channel)
{ … }
static int gb_brightness_set(struct led_classdev *cdev,
enum led_brightness value)
{ … }
static enum led_brightness gb_brightness_get(struct led_classdev *cdev)
{ … }
static int gb_blink_set(struct led_classdev *cdev, unsigned long *delay_on,
unsigned long *delay_off)
{ … }
static void gb_lights_led_operations_set(struct gb_channel *channel,
struct led_classdev *cdev)
{ … }
#if IS_REACHABLE(CONFIG_V4L2_FLASH_LED_CLASS)
static const struct v4l2_flash_ops v4l2_flash_ops;
static void __gb_lights_channel_v4l2_config(struct led_flash_setting *channel_s,
struct led_flash_setting *v4l2_s)
{ … }
static int gb_lights_light_v4l2_register(struct gb_light *light)
{ … }
static void gb_lights_light_v4l2_unregister(struct gb_light *light)
{ … }
#else
static int gb_lights_light_v4l2_register(struct gb_light *light)
{
struct gb_connection *connection = get_conn_from_light(light);
dev_err(&connection->bundle->dev, "no support for v4l2 subdevices\n");
return 0;
}
static void gb_lights_light_v4l2_unregister(struct gb_light *light)
{
}
#endif
#if IS_REACHABLE(CONFIG_LEDS_CLASS_FLASH)
static int gb_lights_flash_intensity_set(struct led_classdev_flash *fcdev,
u32 brightness)
{ … }
static int gb_lights_flash_intensity_get(struct led_classdev_flash *fcdev,
u32 *brightness)
{ … }
static int gb_lights_flash_strobe_set(struct led_classdev_flash *fcdev,
bool state)
{ … }
static int gb_lights_flash_strobe_get(struct led_classdev_flash *fcdev,
bool *state)
{ … }
static int gb_lights_flash_timeout_set(struct led_classdev_flash *fcdev,
u32 timeout)
{ … }
static int gb_lights_flash_fault_get(struct led_classdev_flash *fcdev,
u32 *fault)
{ … }
static const struct led_flash_ops gb_lights_flash_ops = …;
static int __gb_lights_channel_torch_attach(struct gb_channel *channel,
struct gb_channel *channel_torch)
{ … }
static int __gb_lights_flash_led_register(struct gb_channel *channel)
{ … }
static void __gb_lights_flash_led_unregister(struct gb_channel *channel)
{ … }
static int gb_lights_channel_flash_config(struct gb_channel *channel)
{ … }
#else
static int gb_lights_channel_flash_config(struct gb_channel *channel)
{
struct gb_connection *connection = get_conn_from_channel(channel);
dev_err(&connection->bundle->dev, "no support for flash devices\n");
return 0;
}
static int __gb_lights_flash_led_register(struct gb_channel *channel)
{
return 0;
}
static void __gb_lights_flash_led_unregister(struct gb_channel *channel)
{
}
#endif
static int __gb_lights_led_register(struct gb_channel *channel)
{ … }
static int gb_lights_channel_register(struct gb_channel *channel)
{ … }
static void __gb_lights_led_unregister(struct gb_channel *channel)
{ … }
static void gb_lights_channel_unregister(struct gb_channel *channel)
{ … }
static int gb_lights_channel_config(struct gb_light *light,
struct gb_channel *channel)
{ … }
static int gb_lights_light_config(struct gb_lights *glights, u8 id)
{ … }
static int gb_lights_light_register(struct gb_light *light)
{ … }
static void gb_lights_channel_free(struct gb_channel *channel)
{ … }
static void gb_lights_channel_release(struct gb_channel *channel)
{ … }
static void gb_lights_light_release(struct gb_light *light)
{ … }
static void gb_lights_release(struct gb_lights *glights)
{ … }
static int gb_lights_get_count(struct gb_lights *glights)
{ … }
static int gb_lights_create_all(struct gb_lights *glights)
{ … }
static int gb_lights_register_all(struct gb_lights *glights)
{ … }
static int gb_lights_request_handler(struct gb_operation *op)
{ … }
static int gb_lights_probe(struct gb_bundle *bundle,
const struct greybus_bundle_id *id)
{ … }
static void gb_lights_disconnect(struct gb_bundle *bundle)
{ … }
static const struct greybus_bundle_id gb_lights_id_table[] = …;
MODULE_DEVICE_TABLE(greybus, gb_lights_id_table);
static struct greybus_driver gb_lights_driver = …;
module_greybus_driver(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;