Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kc8goq patch 1 #2

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion arch/arm/boot/dts/imx6qdl-hummingboard.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
DOVDD-supply = <&reg_3p3v>;
AVDD-supply = <&reg_3p3v>;
DVDD-supply = <&reg_3p3v>;
pwn-gpios = <&gpio2 10 GPIO_ACTIVE_HIGH>;
// pwn-gpios = <&gpio2 10 GPIO_ACTIVE_HIGH>; // the 15 pin connector has no access to GPIO pin
ipu_id = <0>;
csi_id = <1>;
mclk = <25000000>;
Expand Down
86 changes: 42 additions & 44 deletions drivers/media/platform/mxc/capture/ov5647_mipi.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,11 @@ struct ov5647_mode_info {
};

/*!
* Maintains the information on the current state of the sesor.
* Maintains the information on the current state of the sensor.
*/
static struct sensor_data ov5647_data;
static int pwn_gpio = -EINVAL;
static int pwn_active;
static int rst_gpio = -EINVAL;
static int rst_active;
static int pwn_gpio , rst_gpio;


static struct reg_value ov5647_setting_30fps_960P_1280_960[] = {
{ 0x0100 , 0x00 , 0 , 0 } ,
Expand Down Expand Up @@ -245,42 +243,37 @@ static struct i2c_driver ov5647_i2c_driver = {

static void ov5647_standby(s32 enable)
{
if (!gpio_is_valid(pwn_gpio))
return;


if (enable)
gpio_set_value(pwn_gpio, !pwn_active);
gpio_set_value(pwn_gpio, 1);
else
gpio_set_value(pwn_gpio, pwn_active);
gpio_set_value(pwn_gpio, 0);
pr_debug("ov5647_mipi_camera_powerdown: powerdown=%x, power_gp=0x%x\n", enable, pwn_gpio);
msleep(2);
}

static void ov5647_reset(void)
{
if (!gpio_is_valid(rst_gpio))
return;


/* camera reset */
gpio_set_value(rst_gpio, !rst_active);
gpio_set_value(rst_gpio, 1);

/* camera power dowmn */
if (gpio_is_valid(pwn_gpio)) {
gpio_set_value(pwn_gpio, 1);
msleep(5);
gpio_set_value(pwn_gpio, 1);
msleep(5);

gpio_set_value(pwn_gpio, 0);
msleep(5);
}
gpio_set_value(pwn_gpio, 0);
msleep(5);

gpio_set_value(rst_gpio, rst_active);
gpio_set_value(rst_gpio, 0);
msleep(1);

gpio_set_value(rst_gpio, !rst_active);
gpio_set_value(rst_gpio, 1);
msleep(5);

if (gpio_is_valid(pwn_gpio))
gpio_set_value(pwn_gpio, !pwn_active);
gpio_set_value(pwn_gpio, 1);

}

static int ov5647_power_on(struct device *dev)
Expand Down Expand Up @@ -1066,6 +1059,7 @@ static int ioctl_g_ifparm(struct v4l2_int_device *s, struct v4l2_ifparm *p)
p->u.bt656.bt_sync_correct = 1; /* Indicate external vsync */

return 0;

}

/*!
Expand Down Expand Up @@ -1391,7 +1385,7 @@ static int ioctl_enum_framesizes(struct v4l2_int_device *s,
return -EINVAL;

fsize->pixel_format = ov5647_data.pix.pixelformat;
fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE;
//fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE; //leave defined here?
fsize->discrete.width =
max(ov5647_mode_info_data[0][fsize->index].width,
ov5647_mode_info_data[1][fsize->index].width);
Expand Down Expand Up @@ -1608,35 +1602,39 @@ static int ov5647_probe(struct i2c_client *client,
int retval, init;
u8 chip_id_high, chip_id_low;
struct sensor_data *sensor = &ov5647_data;
enum of_gpio_flags flags;
//enum of_gpio_flags flags;

/* request power down pin */
pwn_gpio = of_get_named_gpio_flags(dev->of_node, "pwn-gpios", 0, &flags);
if (gpio_is_valid(pwn_gpio)) {
pwn_active = !(flags & OF_GPIO_ACTIVE_LOW);
init = (flags & OF_GPIO_ACTIVE_LOW) ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW;
pwn_gpio = of_get_named_gpio_flags(dev->of_node, "pwn-gpios", 0); //, &flags);

if (!gpio_is_valid(pwn_gpio)) {
dev_warn(dev, "no sensor pwdn pin available");
return -EINVAL;
}

retval = devm_gpio_request_one(dev, pwn_gpio, init, "ov5647_mipi_pwdn");
retval = devm_gpio_request_one(dev, pwn_gpio, GPIOF_OUT_INIT_HIGH, "ov5647_mipi_pwdn");
if (retval < 0) {
dev_warn(dev, "request of pwn_gpio failed");
pwn_gpio = -EINVAL;
pwn_gpio = retval;
}
}
}

/* request reset pin */
rst_gpio = of_get_named_gpio_flags(dev->of_node, "rst-gpios", 0, &flags);
if (gpio_is_valid(rst_gpio)) {
rst_active = !(flags & OF_GPIO_ACTIVE_LOW);
init = (flags & OF_GPIO_ACTIVE_LOW) ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW;

retval = devm_gpio_request_one(dev, rst_gpio, init, "ov5647_mipi_reset");
if (retval < 0) {
dev_warn(dev, "request of ov5647_mipi_reset failed");
rst_gpio = -EINVAL;
}
/* request reset pin*/

rst_gpio = of_get_named_gpio(dev->of_node, "rst-gpios", 0);
if (!gpio_is_valid(rst_gpio)) {
dev_warn(dev, "no sensor reset pin available");
return -EINVAL;
}
retval = devm_gpio_request_one(dev, rst_gpio, GPIOF_OUT_INIT_HIGH,
"ov5647_mipi_reset");
if (retval < 0) {
dev_warn(dev, "request of ov5647_mipi_reset failed");
return retval;
}

/* Set initial values for the sensor struct. */
// alternative driver code: http://www.viionsystems.com/UbuntuImages/ov5647_mipi.c
memset(&ov5647_data, 0, sizeof(ov5647_data));

sensor->mipi_camera = 1;
Expand Down Expand Up @@ -1683,7 +1681,7 @@ static int ov5647_probe(struct i2c_client *client,
/* real OV5647 pixelformat is V4L2_PIX_FMT_SBGGR10. */
/* i.MX6 CSI CPD convert 10 bits color data to 8 bits. */
/* (see drivers/mxc/ipu3/ipu_capture.c - _ipu_csi_init) */
ov5647_data.pix.pixelformat = V4L2_PIX_FMT_SBGGR8;
ov5647_data.pix.pixelformat = V4L2_PIX_FMT_SBGGR8; // could try this per other deivers if problem V4L2_PIX_FMT_UYVY
ov5647_data.pix.width = 1280;
ov5647_data.pix.height = 960;
ov5647_data.streamcap.capability = V4L2_MODE_HIGHQUALITY |
Expand Down