• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * vendor/amlogic/media/common/ge2d/stretchblt.c
3  *
4  * Copyright (C) 2017 Amlogic, Inc. All rights reserved.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
14  * more details.
15  *
16  */
17 
18 /* Amlogic Headers */
19 #include <linux/amlogic/media/ge2d/ge2d.h>
20 
_stretchblt(struct ge2d_context_s * wq,int src_x,int src_y,int src_w,int src_h,int dst_x,int dst_y,int dst_w,int dst_h,int block)21 static void _stretchblt(struct ge2d_context_s *wq, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y,
22                         int dst_w, int dst_h, int block)
23 {
24     struct ge2d_cmd_s *ge2d_cmd_cfg = ge2d_wq_get_cmd(wq);
25 
26     ge2d_cmd_cfg->src1_x_start = src_x;
27     ge2d_cmd_cfg->src1_x_end = src_x + src_w - 1;
28     ge2d_cmd_cfg->src1_y_start = src_y;
29     ge2d_cmd_cfg->src1_y_end = src_y + src_h - 1;
30 
31     ge2d_cmd_cfg->dst_x_start = dst_x;
32     ge2d_cmd_cfg->dst_x_end = dst_x + dst_w - 1;
33     ge2d_cmd_cfg->dst_y_start = dst_y;
34     ge2d_cmd_cfg->dst_y_end = dst_y + dst_h - 1;
35 
36     ge2d_cmd_cfg->sc_hsc_en = 1;
37     ge2d_cmd_cfg->sc_vsc_en = 1;
38     ge2d_cmd_cfg->hsc_rpt_p0_num = 1;
39     ge2d_cmd_cfg->vsc_rpt_l0_num = 1;
40     ge2d_cmd_cfg->hsc_div_en = 1;
41 #ifdef CONFIG_GE2D_ADV_NUM
42     ge2d_cmd_cfg->hsc_adv_num = ((dst_w - 1) < 1024L) ? (dst_w - 1) : 0;
43 #else
44     ge2d_cmd_cfg->hsc_adv_num = 0;
45 #endif
46     ge2d_cmd_cfg->color_blend_mode = OPERATION_LOGIC;
47     ge2d_cmd_cfg->color_logic_op = LOGIC_OPERATION_COPY;
48     ge2d_cmd_cfg->alpha_blend_mode = OPERATION_LOGIC;
49     ge2d_cmd_cfg->alpha_logic_op = LOGIC_OPERATION_COPY;
50     ge2d_cmd_cfg->wait_done_flag = block;
51 
52     ge2d_wq_add_work(wq);
53 }
54 
stretchblt(struct ge2d_context_s * wq,int src_x,int src_y,int src_w,int src_h,int dst_x,int dst_y,int dst_w,int dst_h)55 void stretchblt(struct ge2d_context_s *wq, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w,
56                 int dst_h)
57 {
58     _stretchblt(wq, src_x, src_y, src_w, src_h, dst_x, dst_y, dst_w, dst_h, 1);
59 }
60 EXPORT_SYMBOL(stretchblt);
61 
stretchblt_noblk(struct ge2d_context_s * wq,int src_x,int src_y,int src_w,int src_h,int dst_x,int dst_y,int dst_w,int dst_h)62 void stretchblt_noblk(struct ge2d_context_s *wq, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y,
63                       int dst_w, int dst_h)
64 {
65     _stretchblt(wq, src_x, src_y, src_w, src_h, dst_x, dst_y, dst_w, dst_h, 0);
66 }
67 EXPORT_SYMBOL(stretchblt_noblk);
68 
_stretchblt_noalpha(struct ge2d_context_s * wq,int src_x,int src_y,int src_w,int src_h,int dst_x,int dst_y,int dst_w,int dst_h,int blk)69 static void _stretchblt_noalpha(struct ge2d_context_s *wq, int src_x, int src_y, int src_w, int src_h, int dst_x,
70                                 int dst_y, int dst_w, int dst_h, int blk)
71 {
72     struct ge2d_cmd_s *ge2d_cmd_cfg = ge2d_wq_get_cmd(wq);
73     struct ge2d_dp_gen_s *dp_gen_cfg = ge2d_wq_get_dp_gen(wq);
74 
75     if (dp_gen_cfg->alu_const_color != 0xff) {
76         dp_gen_cfg->alu_const_color = 0xff;
77         wq->config.update_flag |= UPDATE_DP_GEN;
78     }
79 
80     ge2d_cmd_cfg->src1_x_start = src_x;
81     ge2d_cmd_cfg->src1_x_end = src_x + src_w - 1;
82     ge2d_cmd_cfg->src1_y_start = src_y;
83     ge2d_cmd_cfg->src1_y_end = src_y + src_h - 1;
84 
85     ge2d_cmd_cfg->dst_x_start = dst_x;
86     ge2d_cmd_cfg->dst_x_end = dst_x + dst_w - 1;
87     ge2d_cmd_cfg->dst_y_start = dst_y;
88     ge2d_cmd_cfg->dst_y_end = dst_y + dst_h - 1;
89 
90     ge2d_cmd_cfg->sc_hsc_en = 1;
91     ge2d_cmd_cfg->sc_vsc_en = 1;
92     ge2d_cmd_cfg->hsc_rpt_p0_num = 1;
93     ge2d_cmd_cfg->vsc_rpt_l0_num = 1;
94     ge2d_cmd_cfg->hsc_div_en = 1;
95 #ifdef CONFIG_GE2D_ADV_NUM
96     ge2d_cmd_cfg->hsc_adv_num = ((dst_w - 1) < 1024L) ? (dst_w - 1) : 0;
97 #else
98     ge2d_cmd_cfg->hsc_adv_num = 0;
99 #endif
100     ge2d_cmd_cfg->color_blend_mode = OPERATION_LOGIC;
101     ge2d_cmd_cfg->color_logic_op = LOGIC_OPERATION_COPY;
102     ge2d_cmd_cfg->alpha_blend_mode = OPERATION_LOGIC;
103     ge2d_cmd_cfg->alpha_logic_op = LOGIC_OPERATION_SET;
104     ge2d_cmd_cfg->wait_done_flag = 1;
105 
106     ge2d_wq_add_work(wq);
107 }
108 
stretchblt_noalpha(struct ge2d_context_s * wq,int src_x,int src_y,int src_w,int src_h,int dst_x,int dst_y,int dst_w,int dst_h)109 void stretchblt_noalpha(struct ge2d_context_s *wq, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y,
110                         int dst_w, int dst_h)
111 {
112     _stretchblt_noalpha(wq, src_x, src_y, src_w, src_h, dst_x, dst_y, dst_w, dst_h, 1);
113 }
114 EXPORT_SYMBOL(stretchblt_noalpha);
115 
stretchblt_noalpha_noblk(struct ge2d_context_s * wq,int src_x,int src_y,int src_w,int src_h,int dst_x,int dst_y,int dst_w,int dst_h)116 void stretchblt_noalpha_noblk(struct ge2d_context_s *wq, int src_x, int src_y, int src_w, int src_h, int dst_x,
117                               int dst_y, int dst_w, int dst_h)
118 {
119     _stretchblt_noalpha(wq, src_x, src_y, src_w, src_h, dst_x, dst_y, dst_w, dst_h, 0);
120 }
121 EXPORT_SYMBOL(stretchblt_noalpha_noblk);
122