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

Adjust Vdec and Venc driver #36

Open
wants to merge 1 commit into
base: JH7100_starlight_multimedia
Choose a base branch
from
Open
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
36 changes: 14 additions & 22 deletions soft_3rdpart/wave511/code/vdi/linux/driver/vdec-starfive.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,6 @@

struct starfive_vdec_data {
struct device *dev;
struct clk *clk_vdec_axi;
struct clk *clk_vdecbrg_main;
struct clk *clk_vdec_bclk;
struct clk *clk_vdec_cclk;
struct clk *clk_vdec_apb;

struct reset_control *rst_vdecbrg_main;
struct reset_control *rst_vdec_axi;
struct reset_control *rst_vdec_bclk;
struct reset_control *rst_vdec_cclk;
struct reset_control *rst_vdec_apb;

struct clk *clk_vdec_id[VDEC_ID_NUM];
struct reset_control *rst_vdec_id[VDEC_ID_NUM];
Expand All @@ -38,8 +27,8 @@ struct starfive_vdec_data {
static struct starfive_vdec_data *sf_vdec = NULL;

const char vdec_data_id[VDEC_ID_NUM][15] = {
"vdec_axi",
"vdecbrg_main",
"vdec_axi",
"vdec_bclk",
"vdec_cclk",
"vdec_apb",
Expand Down Expand Up @@ -71,13 +60,12 @@ void starfive_vdec_rst_exit(void)
{
int i;
int ret;
for (i = 0; i < VDEC_ID_NUM; i++) {
for (i = 1; i < VDEC_ID_NUM; i++) {
/* Assert the reset of "vdecbrg_main" could crash*/
if (i != 1){
ret = reset_control_assert(sf_vdec->rst_vdec_id[i]);
if (ret) {
dev_err(sf_vdec->dev, "reset assert failed\n");
}
ret = reset_control_assert(sf_vdec->rst_vdec_id[i]);
if (ret) {
dev_err(sf_vdec->dev, "VDEC reset assert failed:\n");
dev_err(sf_vdec->dev, vdec_data_id[i]);
}
}
return;
Expand All @@ -86,7 +74,7 @@ void starfive_vdec_rst_exit(void)
void starfive_vdec_clk_exit(void)
{
int i;
for (i = 0; i < VDEC_ID_NUM; i++) {
for (i = 1; i < VDEC_ID_NUM; i++) {
clk_disable_unprepare(sf_vdec->clk_vdec_id[i]);
}
return;
Expand All @@ -99,6 +87,7 @@ static int starfive_vdec_clk_init(void)
for (i = 0; i < VDEC_ID_NUM; i++) {
ret = clk_prepare_enable(sf_vdec->clk_vdec_id[i]);
if (ret) {
dev_err(sf_vdec->dev, "VDEC enable clock failed:\n");
dev_err(sf_vdec->dev, vdec_data_id[i]);
goto init_clk_failed;
}
Expand All @@ -107,7 +96,7 @@ static int starfive_vdec_clk_init(void)
return 0;

init_clk_failed:
for(; i > 0 ; i--) {
for(; i > 1 ; i--) {
clk_disable_unprepare(sf_vdec->clk_vdec_id[i-1]);
}

Expand All @@ -122,6 +111,7 @@ static int starfive_vdec_get_clk(void)
for ( i = 0; i < VDEC_ID_NUM ; i++) {
sf_vdec->clk_vdec_id[i] = devm_clk_get(sf_vdec->dev, vdec_data_id[i]);
if (IS_ERR(sf_vdec->clk_vdec_id[i])) {
dev_err(sf_vdec->dev, "VDEC get clock failed:\n");
dev_err(sf_vdec->dev, vdec_data_id[i]);
ret = PTR_ERR(sf_vdec->clk_vdec_id[i]);
goto get_clk_failed;
Expand All @@ -145,6 +135,7 @@ static int starfive_vdec_reset_init(void)
for (i = 0; i < VDEC_ID_NUM ; i++) {
ret = reset_control_deassert(sf_vdec->rst_vdec_id[i]);
if (ret) {
dev_err(sf_vdec->dev, "VDEC deassert reset failed:\n");
dev_err(sf_vdec->dev, vdec_data_id[i]);
goto init_reset_failed;
}
Expand All @@ -153,7 +144,7 @@ static int starfive_vdec_reset_init(void)
return 0;

init_reset_failed:
for (; i > 0 ; i--) {
for (; i > 1 ; i--) {
reset_control_assert(sf_vdec->rst_vdec_id[i-1]);
}

Expand All @@ -167,6 +158,7 @@ static int starfive_vdec_get_resets(void)
for (i = 0; i < VDEC_ID_NUM ; i++) {
sf_vdec->rst_vdec_id[i] = devm_reset_control_get_exclusive(sf_vdec->dev, vdec_data_id[i]);
if (IS_ERR(sf_vdec->rst_vdec_id[i])) {
dev_err(sf_vdec->dev, "VDEC get reset failed:\n");
dev_err(sf_vdec->dev, vdec_data_id[i]);
ret = PTR_ERR(sf_vdec->rst_vdec_id[i]);
goto get_resets_failed;
Expand Down Expand Up @@ -294,7 +286,7 @@ int starfive_vdec_clk_rst_init(struct platform_device *pdev)
goto init_failed;
}

printk("starfive vdec clock & reset init success.");
dev_info(sf_vdec->dev, "success to init VDEC clock & reset.");
return 0;

init_failed:
Expand Down
2 changes: 1 addition & 1 deletion soft_3rdpart/wave511/code/vdi/linux/driver/vdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1969,7 +1969,7 @@ static int _clk_control(int enable)
else
{
_disable_clk(p_breg+clk_vdec_axi_ctrl_REG_OFFSET,31);
_disable_clk(p_breg+clk_vdecbrg_mainclk_ctrl_REG_OFFSET,31);
// _disable_clk(p_breg+clk_vdecbrg_mainclk_ctrl_REG_OFFSET,31);
_disable_clk(p_breg+clk_vdec_bclk_ctrl_REG_OFFSET,31);
_disable_clk(p_breg+clk_vdec_cclk_ctrl_REG_OFFSET,31);
_disable_clk(p_breg+clk_vdec_apb_ctrl_REG_OFFSET,31);
Expand Down
36 changes: 14 additions & 22 deletions soft_3rdpart/wave521/code/vdi/linux/driver/venc-starfive.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,6 @@

struct starfive_venc_data {
struct device *dev;
struct clk *clk_venc_axi;
struct clk *clk_vencbrg_main;
struct clk *clk_venc_bclk;
struct clk *clk_venc_cclk;
struct clk *clk_venc_apb;

struct reset_control *rst_vencbrg_main;
struct reset_control *rst_venc_axi;
struct reset_control *rst_venc_bclk;
struct reset_control *rst_venc_cclk;
struct reset_control *rst_venc_apb;

struct clk *clk_venc_id[VENC_ID_NUM];
struct reset_control *rst_venc_id[VENC_ID_NUM];
Expand All @@ -37,8 +26,8 @@ struct starfive_venc_data {
static struct starfive_venc_data *sf_venc = NULL;

const char venc_data_id[VENC_ID_NUM][15] = {
"venc_axi",
"vencbrg_main",
"venc_axi",
"venc_bclk",
"venc_cclk",
"venc_apb",
Expand Down Expand Up @@ -70,13 +59,12 @@ void starfive_venc_rst_exit(void)
{
int i;
int ret;
for (i = 0; i < VENC_ID_NUM; i++) {
for (i = 1; i < VENC_ID_NUM; i++) {
/* Assert the reset of "vencbrg_main" could crash*/
if (i != 1 ) {
ret = reset_control_assert(sf_venc->rst_venc_id[i]);
if (ret) {
dev_err(sf_venc->dev, "reset assert failed\n");
}
ret = reset_control_assert(sf_venc->rst_venc_id[i]);
if (ret) {
dev_err(sf_venc->dev, "VENC reset assert failed:\n");
dev_err(sf_venc->dev, venc_data_id[i]);
}
}
return;
Expand All @@ -85,7 +73,7 @@ void starfive_venc_rst_exit(void)
void starfive_venc_clk_exit(void)
{
int i;
for (i = 0; i < VENC_ID_NUM; i++) {
for (i = 1; i < VENC_ID_NUM; i++) {
clk_disable_unprepare(sf_venc->clk_venc_id[i]);
}

Expand All @@ -99,6 +87,7 @@ static int starfive_venc_clk_init(void)
for (i = 0; i < VENC_ID_NUM; i++) {
ret = clk_prepare_enable(sf_venc->clk_venc_id[i]);
if (ret) {
dev_err(sf_venc->dev, "VENC enable clock failed:\n");
dev_err(sf_venc->dev, venc_data_id[i]);
goto init_clk_failed;
}
Expand All @@ -107,7 +96,7 @@ static int starfive_venc_clk_init(void)
return 0;

init_clk_failed:
for(; i > 0 ; i--) {
for(; i > 1 ; i--) {
clk_disable_unprepare(sf_venc->clk_venc_id[i-1]);
}

Expand All @@ -121,6 +110,7 @@ static int starfive_venc_get_clk(void)
for ( i = 0; i < VENC_ID_NUM ; i++) {
sf_venc->clk_venc_id[i] = devm_clk_get(sf_venc->dev, venc_data_id[i]);
if (IS_ERR(sf_venc->clk_venc_id[i])) {
dev_err(sf_venc->dev, "VENC get clock failed:\n");
dev_err(sf_venc->dev, venc_data_id[i]);
ret = PTR_ERR(sf_venc->clk_venc_id[i]);
goto get_clk_failed;
Expand All @@ -144,6 +134,7 @@ static int starfive_venc_reset_init(void)
for (i = 0; i < VENC_ID_NUM ; i++) {
ret = reset_control_deassert(sf_venc->rst_venc_id[i]);
if (ret) {
dev_err(sf_venc->dev, "VENC deassert reset failed:\n");
dev_err(sf_venc->dev, venc_data_id[i]);
goto init_reset_failed;
}
Expand All @@ -152,7 +143,7 @@ static int starfive_venc_reset_init(void)
return 0;

init_reset_failed:
for (; i > 0 ; i--) {
for (; i > 1 ; i--) {
reset_control_assert(sf_venc->rst_venc_id[i-1]);
}

Expand All @@ -167,6 +158,7 @@ static int starfive_venc_get_resets(void)
for (i = 0; i < VENC_ID_NUM ; i++) {
sf_venc->rst_venc_id[i] = devm_reset_control_get_exclusive(sf_venc->dev, venc_data_id[i]);
if (IS_ERR(sf_venc->rst_venc_id[i])) {
dev_err(sf_venc->dev, "VENC get reset failed:\n");
dev_err(sf_venc->dev, venc_data_id[i]);
ret = PTR_ERR(sf_venc->rst_venc_id[i]);
goto get_resets_failed;
Expand Down Expand Up @@ -295,7 +287,7 @@ int starfive_venc_clk_rst_init(struct platform_device *pdev)
}
starfive_venc_rst_status();

printk("starfive venc clock & reset init success.");
dev_info(sf_venc->dev, "success to init VENC clock & reset.");
return 0;

init_failed:
Expand Down
8 changes: 4 additions & 4 deletions soft_3rdpart/wave521/code/vdi/linux/driver/venc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1288,11 +1288,11 @@ static int vpu_probe(struct platform_device *pdev)
dev_info(vpu_dev,"device init.\n");
}

#ifdef VPU_SUPPORT_CLOCK_CONTROL
#ifdef VPU_SUPPORT_CLOCK_CONTROL
vpu_dev->of_node = of_find_node_by_name(NULL, "vpu_enc");
if (!(vpu_dev->of_node))
printk("The node of vpu_enc is not found in device tree.\n");

err = of_address_to_resource(vpu_dev->of_node, 0, &venc_resource[0]);
if (err) {
printk(KERN_ERR "could not find venc register address\n");
Expand All @@ -1301,7 +1301,7 @@ static int vpu_probe(struct platform_device *pdev)

venc_resource[1].start = irq_of_parse_and_map(vpu_dev->of_node, 0);
venc_resource[1].end = venc_resource[1].start;

err = platform_device_add_resources(pdev, venc_resource, 2);
if (err) {
printk(KERN_ERR "could not add venc resource\n");
Expand Down Expand Up @@ -1923,7 +1923,7 @@ static int _clk_control(int enable)
else
{
_disable_clk(p_breg+clk_venc_axi_ctrl_REG_OFFSET,31);
_disable_clk(p_breg+clk_vencbrg_mainclk_ctrl_REG_OFFSET,31);
// _disable_clk(p_breg+clk_vencbrg_mainclk_ctrl_REG_OFFSET,31);
_disable_clk(p_breg+clk_venc_bclk_ctrl_REG_OFFSET,31);
_disable_clk(p_breg+clk_venc_cclk_ctrl_REG_OFFSET,31);
_disable_clk(p_breg+clk_venc_apb_ctrl_REG_OFFSET,31);
Expand Down