summaryrefslogtreecommitdiffstats
path: root/drivers/media/i2c
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@linux.intel.com>2020-02-14 14:49:42 +0100
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>2020-12-03 12:27:31 +0100
commita11d3d6891f042b3537b7f113462bcac8088ba70 (patch)
tree092e0bcaba08ee51bd61435913e5843a15c62b06 /drivers/media/i2c
parentf86ae91627f13f8e1231a782c25c00f4dc08e0c9 (diff)
downloadlinux-a11d3d6891f042b3537b7f113462bcac8088ba70.tar.gz
linux-a11d3d6891f042b3537b7f113462bcac8088ba70.tar.bz2
linux-a11d3d6891f042b3537b7f113462bcac8088ba70.zip
media: ccs: Read CCS static data from firmware binaries
Read the CCS static data for sensors and modules. The files are expected to be found in "ccs" directory. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'drivers/media/i2c')
-rw-r--r--drivers/media/i2c/ccs/ccs-core.c47
-rw-r--r--drivers/media/i2c/ccs/ccs.h2
2 files changed, 48 insertions, 1 deletions
diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c
index 17287a8f539c..be27b002a772 100644
--- a/drivers/media/i2c/ccs/ccs-core.c
+++ b/drivers/media/i2c/ccs/ccs-core.c
@@ -16,6 +16,7 @@
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/device.h>
+#include <linux/firmware.h>
#include <linux/gpio.h>
#include <linux/gpio/consumer.h>
#include <linux/module.h>
@@ -2953,6 +2954,8 @@ out_err:
static int ccs_probe(struct i2c_client *client)
{
struct ccs_sensor *sensor;
+ const struct firmware *fw;
+ char filename[40];
unsigned int i;
int rval;
@@ -3042,9 +3045,43 @@ static int ccs_probe(struct i2c_client *client)
goto out_power_off;
}
+ rval = snprintf(filename, sizeof(filename),
+ "ccs/ccs-sensor-%4.4x-%4.4x-%4.4x.fw",
+ sensor->minfo.sensor_mipi_manufacturer_id,
+ sensor->minfo.sensor_model_id,
+ sensor->minfo.sensor_revision_number);
+ if (rval >= sizeof(filename)) {
+ rval = -ENOMEM;
+ goto out_power_off;
+ }
+
+ rval = request_firmware(&fw, filename, &client->dev);
+ if (!rval) {
+ ccs_data_parse(&sensor->sdata, fw->data, fw->size, &client->dev,
+ true);
+ release_firmware(fw);
+ }
+
+ rval = snprintf(filename, sizeof(filename),
+ "ccs/ccs-module-%4.4x-%4.4x-%4.4x.fw",
+ sensor->minfo.mipi_manufacturer_id,
+ sensor->minfo.model_id,
+ sensor->minfo.revision_number);
+ if (rval >= sizeof(filename)) {
+ rval = -ENOMEM;
+ goto out_release_sdata;
+ }
+
+ rval = request_firmware(&fw, filename, &client->dev);
+ if (!rval) {
+ ccs_data_parse(&sensor->mdata, fw->data, fw->size, &client->dev,
+ true);
+ release_firmware(fw);
+ }
+
rval = ccs_read_all_limits(sensor);
if (rval)
- goto out_power_off;
+ goto out_release_mdata;
rval = ccs_read_frame_fmt(sensor);
if (rval) {
@@ -3208,6 +3245,12 @@ out_media_entity_cleanup:
out_cleanup:
ccs_cleanup(sensor);
+out_release_mdata:
+ kvfree(sensor->mdata.backing);
+
+out_release_sdata:
+ kvfree(sensor->sdata.backing);
+
out_free_ccs_limits:
kfree(sensor->ccs_limits);
@@ -3238,6 +3281,8 @@ static int ccs_remove(struct i2c_client *client)
ccs_cleanup(sensor);
mutex_destroy(&sensor->mutex);
kfree(sensor->ccs_limits);
+ kvfree(sensor->sdata.backing);
+ kvfree(sensor->mdata.backing);
return 0;
}
diff --git a/drivers/media/i2c/ccs/ccs.h b/drivers/media/i2c/ccs/ccs.h
index ad2ff5a74424..cbcd93b519da 100644
--- a/drivers/media/i2c/ccs/ccs.h
+++ b/drivers/media/i2c/ccs/ccs.h
@@ -16,6 +16,7 @@
#include <media/v4l2-ctrls.h>
#include <media/v4l2-subdev.h>
+#include "ccs-data.h"
#include "ccs-quirk.h"
#include "ccs-regs.h"
#include "ccs-reg-access.h"
@@ -227,6 +228,7 @@ struct ccs_sensor {
const struct ccs_csi_data_format *internal_csi_format;
u32 default_mbus_frame_fmts;
int default_pixel_order;
+ struct ccs_data_container sdata, mdata;
u8 binning_horizontal;
u8 binning_vertical;