msm: camera: sensor: Replace cma_alloc with vmalloc
Replace cma_alloc() api with vmalloc() in order to accommodate kernel upgrade and DLKM/Builtin support. CRs-Fixed: 2572607 Change-Id: If8caaefe5ac333998bd8c4868f16e586ee749e8a Signed-off-by: Jigarkumar Zala <jzala@codeaurora.org>
This commit is contained in:

committed by
Gerrit - the friendly Code Review server

parent
9d1a4364ae
commit
6283836b38
@@ -300,7 +300,7 @@ static int cam_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl)
|
|||||||
char name_coeff[32] = {0};
|
char name_coeff[32] = {0};
|
||||||
struct device *dev = &(o_ctrl->pdev->dev);
|
struct device *dev = &(o_ctrl->pdev->dev);
|
||||||
struct cam_sensor_i2c_reg_setting i2c_reg_setting;
|
struct cam_sensor_i2c_reg_setting i2c_reg_setting;
|
||||||
struct page *page = NULL;
|
void *vaddr = NULL;
|
||||||
|
|
||||||
if (!o_ctrl) {
|
if (!o_ctrl) {
|
||||||
CAM_ERR(CAM_OIS, "Invalid Args");
|
CAM_ERR(CAM_OIS, "Invalid Args");
|
||||||
@@ -327,18 +327,17 @@ static int cam_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl)
|
|||||||
i2c_reg_setting.data_type = CAMERA_SENSOR_I2C_TYPE_BYTE;
|
i2c_reg_setting.data_type = CAMERA_SENSOR_I2C_TYPE_BYTE;
|
||||||
i2c_reg_setting.size = total_bytes;
|
i2c_reg_setting.size = total_bytes;
|
||||||
i2c_reg_setting.delay = 0;
|
i2c_reg_setting.delay = 0;
|
||||||
fw_size = PAGE_ALIGN(sizeof(struct cam_sensor_i2c_reg_array) *
|
fw_size = (sizeof(struct cam_sensor_i2c_reg_array) * total_bytes);
|
||||||
total_bytes) >> PAGE_SHIFT;
|
vaddr = vmalloc(fw_size);
|
||||||
page = cma_alloc(dev_get_cma_area((o_ctrl->soc_info.dev)),
|
if (!vaddr) {
|
||||||
fw_size, 0, GFP_KERNEL);
|
CAM_ERR(CAM_OIS,
|
||||||
if (!page) {
|
"Failed in allocating i2c_array: fw_size: %u", fw_size);
|
||||||
CAM_ERR(CAM_OIS, "Failed in allocating i2c_array");
|
|
||||||
release_firmware(fw);
|
release_firmware(fw);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
i2c_reg_setting.reg_setting = (struct cam_sensor_i2c_reg_array *) (
|
i2c_reg_setting.reg_setting = (struct cam_sensor_i2c_reg_array *) (
|
||||||
page_address(page));
|
vaddr);
|
||||||
|
|
||||||
for (cnt = 0, ptr = (uint8_t *)fw->data; cnt < total_bytes;
|
for (cnt = 0, ptr = (uint8_t *)fw->data; cnt < total_bytes;
|
||||||
cnt++, ptr++) {
|
cnt++, ptr++) {
|
||||||
@@ -355,9 +354,8 @@ static int cam_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl)
|
|||||||
CAM_ERR(CAM_OIS, "OIS FW download failed %d", rc);
|
CAM_ERR(CAM_OIS, "OIS FW download failed %d", rc);
|
||||||
goto release_firmware;
|
goto release_firmware;
|
||||||
}
|
}
|
||||||
cma_release(dev_get_cma_area((o_ctrl->soc_info.dev)),
|
vfree(vaddr);
|
||||||
page, fw_size);
|
vaddr = NULL;
|
||||||
page = NULL;
|
|
||||||
fw_size = 0;
|
fw_size = 0;
|
||||||
release_firmware(fw);
|
release_firmware(fw);
|
||||||
|
|
||||||
@@ -372,18 +370,17 @@ static int cam_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl)
|
|||||||
i2c_reg_setting.data_type = CAMERA_SENSOR_I2C_TYPE_BYTE;
|
i2c_reg_setting.data_type = CAMERA_SENSOR_I2C_TYPE_BYTE;
|
||||||
i2c_reg_setting.size = total_bytes;
|
i2c_reg_setting.size = total_bytes;
|
||||||
i2c_reg_setting.delay = 0;
|
i2c_reg_setting.delay = 0;
|
||||||
fw_size = PAGE_ALIGN(sizeof(struct cam_sensor_i2c_reg_array) *
|
fw_size = (sizeof(struct cam_sensor_i2c_reg_array) * total_bytes);
|
||||||
total_bytes) >> PAGE_SHIFT;
|
vaddr = vmalloc(fw_size);
|
||||||
page = cma_alloc(dev_get_cma_area((o_ctrl->soc_info.dev)),
|
if (!vaddr) {
|
||||||
fw_size, 0, GFP_KERNEL);
|
CAM_ERR(CAM_OIS,
|
||||||
if (!page) {
|
"Failed in allocating i2c_array: fw_size: %u", fw_size);
|
||||||
CAM_ERR(CAM_OIS, "Failed in allocating i2c_array");
|
|
||||||
release_firmware(fw);
|
release_firmware(fw);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
i2c_reg_setting.reg_setting = (struct cam_sensor_i2c_reg_array *) (
|
i2c_reg_setting.reg_setting = (struct cam_sensor_i2c_reg_array *) (
|
||||||
page_address(page));
|
vaddr);
|
||||||
|
|
||||||
for (cnt = 0, ptr = (uint8_t *)fw->data; cnt < total_bytes;
|
for (cnt = 0, ptr = (uint8_t *)fw->data; cnt < total_bytes;
|
||||||
cnt++, ptr++) {
|
cnt++, ptr++) {
|
||||||
@@ -400,10 +397,10 @@ static int cam_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl)
|
|||||||
CAM_ERR(CAM_OIS, "OIS FW download failed %d", rc);
|
CAM_ERR(CAM_OIS, "OIS FW download failed %d", rc);
|
||||||
|
|
||||||
release_firmware:
|
release_firmware:
|
||||||
cma_release(dev_get_cma_area((o_ctrl->soc_info.dev)),
|
vfree(vaddr);
|
||||||
page, fw_size);
|
vaddr = NULL;
|
||||||
|
fw_size = 0;
|
||||||
release_firmware(fw);
|
release_firmware(fw);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -111,7 +111,8 @@ static int32_t cam_spi_tx_helper(struct camera_io_master *client,
|
|||||||
uint32_t len, hlen;
|
uint32_t len, hlen;
|
||||||
uint8_t retries = client->spi_client->retries;
|
uint8_t retries = client->spi_client->retries;
|
||||||
uint32_t txr = 0, rxr = 0;
|
uint32_t txr = 0, rxr = 0;
|
||||||
struct page *page_tx = NULL, *page_rx = NULL;
|
void *vaddr_tx = NULL;
|
||||||
|
void *vaddr_rx = NULL;
|
||||||
|
|
||||||
hlen = cam_camera_spi_get_hlen(inst);
|
hlen = cam_camera_spi_get_hlen(inst);
|
||||||
len = hlen + num_byte;
|
len = hlen + num_byte;
|
||||||
@@ -125,30 +126,32 @@ static int32_t cam_spi_tx_helper(struct camera_io_master *client,
|
|||||||
if (tx) {
|
if (tx) {
|
||||||
ctx = tx;
|
ctx = tx;
|
||||||
} else {
|
} else {
|
||||||
txr = PAGE_ALIGN(len) >> PAGE_SHIFT;
|
txr = len;
|
||||||
page_tx = cma_alloc(dev_get_cma_area(dev),
|
vaddr_tx = vmalloc(txr);
|
||||||
txr, 0, GFP_KERNEL);
|
if (!vaddr_tx) {
|
||||||
if (!page_tx)
|
CAM_ERR(CAM_SENSOR,
|
||||||
|
"Fail to allocate Memory: len: %u", txr);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
ctx = page_address(page_tx);
|
ctx = (char *)vaddr_tx;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num_byte) {
|
if (num_byte) {
|
||||||
if (rx) {
|
if (rx) {
|
||||||
crx = rx;
|
crx = rx;
|
||||||
} else {
|
} else {
|
||||||
rxr = PAGE_ALIGN(len) >> PAGE_SHIFT;
|
rxr = len;
|
||||||
page_rx = cma_alloc(dev_get_cma_area(dev),
|
vaddr_rx = vmalloc(rxr);
|
||||||
rxr, 0, GFP_KERNEL);
|
if (!vaddr_rx) {
|
||||||
if (!page_rx) {
|
|
||||||
if (!tx)
|
if (!tx)
|
||||||
cma_release(dev_get_cma_area(dev),
|
vfree(vaddr_tx);
|
||||||
page_tx, txr);
|
CAM_ERR(CAM_SENSOR,
|
||||||
|
"Fail to allocate memory: len: %u",
|
||||||
|
rxr);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
crx = page_address(page_rx);
|
crx = (char *)vaddr_rx;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
crx = NULL;
|
crx = NULL;
|
||||||
@@ -169,9 +172,11 @@ static int32_t cam_spi_tx_helper(struct camera_io_master *client,
|
|||||||
|
|
||||||
out:
|
out:
|
||||||
if (!tx)
|
if (!tx)
|
||||||
cma_release(dev_get_cma_area(dev), page_tx, txr);
|
vfree(vaddr_tx);
|
||||||
|
vaddr_tx = NULL;
|
||||||
if (!rx)
|
if (!rx)
|
||||||
cma_release(dev_get_cma_area(dev), page_rx, rxr);
|
vfree(vaddr_rx);
|
||||||
|
vaddr_rx = NULL;
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user