linux/drivers/media/i2c/ccs/ccs-core.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * drivers/media/i2c/ccs/ccs-core.c
 *
 * Generic driver for MIPI CCS/SMIA/SMIA++ compliant camera sensors
 *
 * Copyright (C) 2020 Intel Corporation
 * Copyright (C) 2010--2012 Nokia Corporation
 * Contact: Sakari Ailus <[email protected]>
 *
 * Based on smiapp driver by Vimarsh Zutshi
 * Based on jt8ev1.c by Vimarsh Zutshi
 * Based on smia-sensor.c by Tuukka Toivonen <[email protected]>
 */

#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/firmware.h>
#include <linux/gpio/consumer.h>
#include <linux/module.h>
#include <linux/pm_runtime.h>
#include <linux/property.h>
#include <linux/regulator/consumer.h>
#include <linux/slab.h>
#include <linux/smiapp.h>
#include <linux/v4l2-mediabus.h>
#include <media/v4l2-cci.h>
#include <media/v4l2-device.h>
#include <media/v4l2-fwnode.h>
#include <uapi/linux/ccs.h>

#include "ccs.h"

#define CCS_ALIGN_DIM(dim, flags)

static struct ccs_limit_offset {} ccs_limit_offsets[CCS_L_LAST + 1];

/*
 * ccs_module_idents - supported camera modules
 */
static const struct ccs_module_ident ccs_module_idents[] =;

#define CCS_DEVICE_FLAG_IS_SMIA

struct ccs_device {};

static const char * const ccs_regulators[] =;

/*
 *
 * Dynamic Capability Identification
 *
 */

static void ccs_assign_limit(void *ptr, unsigned int width, u32 val)
{}

static int ccs_limit_ptr(struct ccs_sensor *sensor, unsigned int limit,
			 unsigned int offset, void **__ptr)
{}

void ccs_replace_limit(struct ccs_sensor *sensor,
		       unsigned int limit, unsigned int offset, u32 val)
{}

u32 ccs_get_limit(struct ccs_sensor *sensor, unsigned int limit,
		  unsigned int offset)
{}

static int ccs_read_all_limits(struct ccs_sensor *sensor)
{}

static int ccs_read_frame_fmt(struct ccs_sensor *sensor)
{}

static int ccs_pll_configure(struct ccs_sensor *sensor)
{}

static int ccs_pll_try(struct ccs_sensor *sensor, struct ccs_pll *pll)
{}

static int ccs_pll_update(struct ccs_sensor *sensor)
{}


/*
 *
 * V4L2 Controls handling
 *
 */

static void __ccs_update_exposure_limits(struct ccs_sensor *sensor)
{}

/*
 * Order matters.
 *
 * 1. Bits-per-pixel, descending.
 * 2. Bits-per-pixel compressed, descending.
 * 3. Pixel order, same as in pixel_order_str. Formats for all four pixel
 *    orders must be defined.
 */
static const struct ccs_csi_data_format ccs_csi_data_formats[] =;

static const char *pixel_order_str[] =;

#define to_csi_format_idx(fmt)

static u32 ccs_pixel_order(struct ccs_sensor *sensor)
{}

static void ccs_update_mbus_formats(struct ccs_sensor *sensor)
{}

static const char * const ccs_test_patterns[] =;

static int ccs_set_ctrl(struct v4l2_ctrl *ctrl)
{}

static const struct v4l2_ctrl_ops ccs_ctrl_ops =;

static int ccs_init_controls(struct ccs_sensor *sensor)
{}

/*
 * For controls that require information on available media bus codes
 * and linke frequencies.
 */
static int ccs_init_late_controls(struct ccs_sensor *sensor)
{}

static void ccs_free_controls(struct ccs_sensor *sensor)
{}

static int ccs_get_mbus_formats(struct ccs_sensor *sensor)
{}

static void ccs_update_blanking(struct ccs_sensor *sensor)
{}

static int ccs_pll_blanking_update(struct ccs_sensor *sensor)
{}

/*
 *
 * SMIA++ NVM handling
 *
 */

static int ccs_read_nvm_page(struct ccs_sensor *sensor, u32 p, u8 *nvm,
			     u8 *status)
{}

static int ccs_read_nvm(struct ccs_sensor *sensor, unsigned char *nvm,
			size_t nvm_size)
{}

/*
 *
 * SMIA++ CCI address control
 *
 */
static int ccs_change_cci_addr(struct ccs_sensor *sensor)
{}

/*
 *
 * SMIA++ Mode Control
 *
 */
static int ccs_setup_flash_strobe(struct ccs_sensor *sensor)
{}

/* -----------------------------------------------------------------------------
 * Power management
 */

static int ccs_write_msr_regs(struct ccs_sensor *sensor)
{}

static int ccs_update_phy_ctrl(struct ccs_sensor *sensor)
{}

static int ccs_power_on(struct device *dev)
{}

static int ccs_power_off(struct device *dev)
{}

/* -----------------------------------------------------------------------------
 * Video stream management
 */

static int ccs_start_streaming(struct ccs_sensor *sensor)
{}

static int ccs_stop_streaming(struct ccs_sensor *sensor)
{}

/* -----------------------------------------------------------------------------
 * V4L2 subdev video operations
 */

static int ccs_pm_get_init(struct ccs_sensor *sensor)
{}

static int ccs_set_stream(struct v4l2_subdev *subdev, int enable)
{}

static int ccs_pre_streamon(struct v4l2_subdev *subdev, u32 flags)
{}

static int ccs_post_streamoff(struct v4l2_subdev *subdev)
{}

static int ccs_enum_mbus_code(struct v4l2_subdev *subdev,
			      struct v4l2_subdev_state *sd_state,
			      struct v4l2_subdev_mbus_code_enum *code)
{}

static u32 __ccs_get_mbus_code(struct v4l2_subdev *subdev, unsigned int pad)
{}

static int __ccs_get_format(struct v4l2_subdev *subdev,
			    struct v4l2_subdev_state *sd_state,
			    struct v4l2_subdev_format *fmt)
{}

static int ccs_get_format(struct v4l2_subdev *subdev,
			  struct v4l2_subdev_state *sd_state,
			  struct v4l2_subdev_format *fmt)
{}

static void ccs_get_crop_compose(struct v4l2_subdev *subdev,
				 struct v4l2_subdev_state *sd_state,
				 struct v4l2_rect **crops,
				 struct v4l2_rect **comps)
{}

/* Changes require propagation only on sink pad. */
static void ccs_propagate(struct v4l2_subdev *subdev,
			  struct v4l2_subdev_state *sd_state, int which,
			  int target)
{}

static const struct ccs_csi_data_format
*ccs_validate_csi_data_format(struct ccs_sensor *sensor, u32 code)
{}

static int ccs_set_format_source(struct v4l2_subdev *subdev,
				 struct v4l2_subdev_state *sd_state,
				 struct v4l2_subdev_format *fmt)
{}

static int ccs_set_format(struct v4l2_subdev *subdev,
			  struct v4l2_subdev_state *sd_state,
			  struct v4l2_subdev_format *fmt)
{}

/*
 * Calculate goodness of scaled image size compared to expected image
 * size and flags provided.
 */
#define SCALING_GOODNESS
#define SCALING_GOODNESS_EXTREME
static int scaling_goodness(struct v4l2_subdev *subdev, int w, int ask_w,
			    int h, int ask_h, u32 flags)
{}

static void ccs_set_compose_binner(struct v4l2_subdev *subdev,
				   struct v4l2_subdev_state *sd_state,
				   struct v4l2_subdev_selection *sel,
				   struct v4l2_rect **crops,
				   struct v4l2_rect *comp)
{}

/*
 * Calculate best scaling ratio and mode for given output resolution.
 *
 * Try all of these: horizontal ratio, vertical ratio and smallest
 * size possible (horizontally).
 *
 * Also try whether horizontal scaler or full scaler gives a better
 * result.
 */
static void ccs_set_compose_scaler(struct v4l2_subdev *subdev,
				   struct v4l2_subdev_state *sd_state,
				   struct v4l2_subdev_selection *sel,
				   struct v4l2_rect **crops,
				   struct v4l2_rect *comp)
{}
/* We're only called on source pads. This function sets scaling. */
static int ccs_set_compose(struct v4l2_subdev *subdev,
			   struct v4l2_subdev_state *sd_state,
			   struct v4l2_subdev_selection *sel)
{}

static int ccs_sel_supported(struct v4l2_subdev *subdev,
			     struct v4l2_subdev_selection *sel)
{}

static int ccs_set_crop(struct v4l2_subdev *subdev,
			struct v4l2_subdev_state *sd_state,
			struct v4l2_subdev_selection *sel)
{}

static void ccs_get_native_size(struct ccs_subdev *ssd, struct v4l2_rect *r)
{}

static int ccs_get_selection(struct v4l2_subdev *subdev,
			     struct v4l2_subdev_state *sd_state,
			     struct v4l2_subdev_selection *sel)
{}

static int ccs_set_selection(struct v4l2_subdev *subdev,
			     struct v4l2_subdev_state *sd_state,
			     struct v4l2_subdev_selection *sel)
{}

static int ccs_get_skip_frames(struct v4l2_subdev *subdev, u32 *frames)
{}

static int ccs_get_skip_top_lines(struct v4l2_subdev *subdev, u32 *lines)
{}

/* -----------------------------------------------------------------------------
 * sysfs attributes
 */

static ssize_t
nvm_show(struct device *dev, struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(nvm);

static ssize_t
ident_show(struct device *dev, struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(ident);

/* -----------------------------------------------------------------------------
 * V4L2 subdev core operations
 */

static int ccs_identify_module(struct ccs_sensor *sensor)
{}

static const struct v4l2_subdev_ops ccs_ops;
static const struct media_entity_operations ccs_entity_ops;

static int ccs_register_subdev(struct ccs_sensor *sensor,
			       struct ccs_subdev *ssd,
			       struct ccs_subdev *sink_ssd,
			       u16 source_pad, u16 sink_pad, u32 link_flags)
{}

static void ccs_unregistered(struct v4l2_subdev *subdev)
{}

static int ccs_registered(struct v4l2_subdev *subdev)
{}

static void ccs_cleanup(struct ccs_sensor *sensor)
{}

static int ccs_init_subdev(struct ccs_sensor *sensor,
			   struct ccs_subdev *ssd, const char *name,
			   unsigned short num_pads, u32 function,
			   const char *lock_name,
			   struct lock_class_key *lock_key)
{}

static int ccs_init_state(struct v4l2_subdev *sd,
			  struct v4l2_subdev_state *sd_state)
{}

static const struct v4l2_subdev_video_ops ccs_video_ops =;

static const struct v4l2_subdev_pad_ops ccs_pad_ops =;

static const struct v4l2_subdev_sensor_ops ccs_sensor_ops =;

static const struct v4l2_subdev_ops ccs_ops =;

static const struct media_entity_operations ccs_entity_ops =;

static const struct v4l2_subdev_internal_ops ccs_internal_src_ops =;

/* -----------------------------------------------------------------------------
 * I2C Driver
 */

static int ccs_get_hwconfig(struct ccs_sensor *sensor, struct device *dev)
{}

static int ccs_firmware_name(struct i2c_client *client,
			     struct ccs_sensor *sensor, char *filename,
			     size_t filename_size, bool is_module)
{}

static int ccs_probe(struct i2c_client *client)
{}

static void ccs_remove(struct i2c_client *client)
{}

static const struct ccs_device smia_device =;

static const struct ccs_device ccs_device =;

static const struct acpi_device_id ccs_acpi_table[] =;
MODULE_DEVICE_TABLE(acpi, ccs_acpi_table);

static const struct of_device_id ccs_of_table[] =;
MODULE_DEVICE_TABLE(of, ccs_of_table);

static const struct dev_pm_ops ccs_pm_ops =;

static struct i2c_driver ccs_i2c_driver =;

static int ccs_module_init(void)
{}

static void ccs_module_cleanup(void)
{}

module_init();
module_exit(ccs_module_cleanup);

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();
MODULE_ALIAS();