Commit 1aace3da authored by Hans de Goede's avatar Hans de Goede Committed by Mauro Carvalho Chehab

media: atomisp: gc0310: Turn into standard v4l2 sensor driver

Switch the atomisp-gc0310 driver to v4l2 async device registration.

After this change this driver no longer depends on
atomisp_gmin_platform and all atomisp-isms are gone.

Link: https://lore.kernel.org/r/20230525190100.130010-4-hdegoede@redhat.comReviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent 947550f8
...@@ -29,8 +29,6 @@ ...@@ -29,8 +29,6 @@
#include <media/v4l2-ctrls.h> #include <media/v4l2-ctrls.h>
#include <media/v4l2-device.h> #include <media/v4l2-device.h>
#include "../include/linux/atomisp_gmin_platform.h"
#define GC0310_NATIVE_WIDTH 656 #define GC0310_NATIVE_WIDTH 656
#define GC0310_NATIVE_HEIGHT 496 #define GC0310_NATIVE_HEIGHT 496
...@@ -85,6 +83,7 @@ struct gc0310_device { ...@@ -85,6 +83,7 @@ struct gc0310_device {
struct mutex input_lock; struct mutex input_lock;
bool is_streaming; bool is_streaming;
struct fwnode_handle *ep_fwnode;
struct gpio_desc *reset; struct gpio_desc *reset;
struct gpio_desc *powerdown; struct gpio_desc *powerdown;
...@@ -596,11 +595,11 @@ static void gc0310_remove(struct i2c_client *client) ...@@ -596,11 +595,11 @@ static void gc0310_remove(struct i2c_client *client)
dev_dbg(&client->dev, "gc0310_remove...\n"); dev_dbg(&client->dev, "gc0310_remove...\n");
atomisp_unregister_subdev(sd); v4l2_async_unregister_subdev(sd);
v4l2_device_unregister_subdev(sd);
media_entity_cleanup(&dev->sd.entity); media_entity_cleanup(&dev->sd.entity);
v4l2_ctrl_handler_free(&dev->ctrls.handler); v4l2_ctrl_handler_free(&dev->ctrls.handler);
mutex_destroy(&dev->input_lock); mutex_destroy(&dev->input_lock);
fwnode_handle_put(dev->ep_fwnode);
pm_runtime_disable(&client->dev); pm_runtime_disable(&client->dev);
} }
...@@ -613,19 +612,27 @@ static int gc0310_probe(struct i2c_client *client) ...@@ -613,19 +612,27 @@ static int gc0310_probe(struct i2c_client *client)
if (!dev) if (!dev)
return -ENOMEM; return -ENOMEM;
ret = v4l2_get_acpi_sensor_info(&client->dev, NULL); /*
if (ret) * Sometimes the fwnode graph is initialized by the bridge driver.
return ret; * Bridge drivers doing this may also add GPIO mappings, wait for this.
*/
dev->ep_fwnode = fwnode_graph_get_next_endpoint(dev_fwnode(&client->dev), NULL);
if (!dev->ep_fwnode)
return dev_err_probe(&client->dev, -EPROBE_DEFER, "waiting for fwnode graph endpoint\n");
dev->reset = devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_HIGH); dev->reset = devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(dev->reset)) if (IS_ERR(dev->reset)) {
fwnode_handle_put(dev->ep_fwnode);
return dev_err_probe(&client->dev, PTR_ERR(dev->reset), return dev_err_probe(&client->dev, PTR_ERR(dev->reset),
"getting reset GPIO\n"); "getting reset GPIO\n");
}
dev->powerdown = devm_gpiod_get(&client->dev, "powerdown", GPIOD_OUT_HIGH); dev->powerdown = devm_gpiod_get(&client->dev, "powerdown", GPIOD_OUT_HIGH);
if (IS_ERR(dev->powerdown)) if (IS_ERR(dev->powerdown)) {
fwnode_handle_put(dev->ep_fwnode);
return dev_err_probe(&client->dev, PTR_ERR(dev->powerdown), return dev_err_probe(&client->dev, PTR_ERR(dev->powerdown),
"getting powerdown GPIO\n"); "getting powerdown GPIO\n");
}
mutex_init(&dev->input_lock); mutex_init(&dev->input_lock);
v4l2_i2c_subdev_init(&dev->sd, client, &gc0310_ops); v4l2_i2c_subdev_init(&dev->sd, client, &gc0310_ops);
...@@ -645,6 +652,7 @@ static int gc0310_probe(struct i2c_client *client) ...@@ -645,6 +652,7 @@ static int gc0310_probe(struct i2c_client *client)
dev->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; dev->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
dev->pad.flags = MEDIA_PAD_FL_SOURCE; dev->pad.flags = MEDIA_PAD_FL_SOURCE;
dev->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR; dev->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
dev->sd.fwnode = dev->ep_fwnode;
ret = gc0310_init_controls(dev); ret = gc0310_init_controls(dev);
if (ret) { if (ret) {
...@@ -658,8 +666,7 @@ static int gc0310_probe(struct i2c_client *client) ...@@ -658,8 +666,7 @@ static int gc0310_probe(struct i2c_client *client)
return ret; return ret;
} }
ret = atomisp_register_sensor_no_gmin(&dev->sd, 1, ATOMISP_INPUT_FORMAT_RAW_8, ret = v4l2_async_register_subdev_sensor(&dev->sd);
atomisp_bayer_order_grbg);
if (ret) { if (ret) {
gc0310_remove(client); gc0310_remove(client);
return ret; return ret;
......
...@@ -89,6 +89,8 @@ static const guid_t atomisp_dsm_guid = ...@@ -89,6 +89,8 @@ static const guid_t atomisp_dsm_guid =
* power-management and with v4l2-async probing. * power-management and with v4l2-async probing.
*/ */
static const struct atomisp_csi2_sensor_config supported_sensors[] = { static const struct atomisp_csi2_sensor_config supported_sensors[] = {
/* GalaxyCore GC0310 */
{ "INT0310", 1 },
/* Omnivision OV2680 */ /* Omnivision OV2680 */
{ "OVTI2680", 1 }, { "OVTI2680", 1 },
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment