huangcm
2025-07-03 c26084b3642f262f858535ab4e46c1e9b520d3a1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
/*
 * drivers/video/sunxi/disp2/disp/de/lowlevel_v2x/de_ccsc.c
 *
 * Copyright (c) 2007-2019 Allwinnertech Co., Ltd.
 * Author: zhengxiaobin <zhengxiaobin@allwinnertech.com>
 *
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
 * may be copied, distributed, and modified under those terms.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */
#include "de_rtmx.h"
#include "de_csc_type.h"
#include "de_vep_table.h"
#include "de_csc.h"
#include "de_enhance.h"
 
#define CCSC00_OFST    0xAA050
/* device0 channel0 (or device1 channel0 support vep) */
#if defined(CONFIG_MACH_SUN8IW17)
#define CCSC01_OFST 0xF0000
#else
#define CCSC01_OFST 0xFA050
#endif /*endif CONFIG_MACH_SUN8IW17 */
/* device0 channel1 (or device1 channel1 support vep) */
#define CCSC10_OFST 0xA0000
/* device1 channel0 not support vep */
#define CCSC11_OFST 0xF0000
/* device1 channel1 not support vep */
#define ICSC0_OFST  0xA0040
#define ICSC1_OFST  0xF0040
 
static volatile struct __csc_reg_t *ccsc_dev[DE_NUM][CHN_NUM];
static volatile struct __icsc_reg_t *icsc_dev[DE_NUM][CHN_NUM];
static struct de_reg_blocks csc_block[DE_NUM][CHN_NUM];
static struct de_reg_blocks icsc_block[DE_NUM][CHN_NUM];
 
static unsigned int vi_num[DE_NUM];
static unsigned int vep_support[DE_NUM][CHN_NUM];
 
static int de_ccsc_set_reg_base(unsigned int sel, unsigned int chno, void *base)
{
   __inf("sel=%d, chno=%d, base=0x%p\n", sel, chno, base);
   ccsc_dev[sel][chno] = (struct __csc_reg_t *) base;
 
   return 0;
}
 
static int de_icsc_set_reg_base(unsigned int sel, unsigned int chno, void *base)
{
   __inf("sel=%d, chno=%d, base=0x%p\n", sel, chno, base);
   icsc_dev[sel][chno] = (struct __icsc_reg_t *) base;
 
   return 0;
}
 
int de_ccsc_apply(unsigned int sel, unsigned int ch_id,
         struct disp_csc_config *config)
{
   int csc_coeff[12];
   unsigned int in_fmt, in_mode, out_fmt, out_mode;
 
   /* enable FCE CSC when UI(RGB format) input */
   if (vep_support[sel][ch_id]) {
       if (config->in_fmt == DE_RGB && config->out_fmt == DE_RGB) {
           icsc_dev[sel][ch_id]->bypass.bits.enable = 1;
           icsc_block[sel][ch_id].dirty = 1;
 
           in_fmt = DE_YUV;
           in_mode = DE_ENHANCE;
           out_fmt = DE_RGB;
           out_mode = DE_BT601;
       } else {
           icsc_dev[sel][ch_id]->bypass.bits.enable = 0;
           icsc_block[sel][ch_id].dirty = 1;
 
           in_fmt = config->in_fmt;
           in_mode = config->in_mode;
           out_fmt = config->out_fmt;
           out_mode = config->out_mode;
       }
 
   } else {
       in_fmt = config->in_fmt;
       in_mode = config->in_mode;
       out_fmt = config->out_fmt;
       out_mode = config->out_mode;
   }
 
   de_csc_coeff_calc(in_fmt, in_mode, out_fmt, out_mode,
             config->brightness, config->contrast,
             config->saturation, config->hue,
             config->out_color_range, csc_coeff);
 
   ccsc_dev[sel][ch_id]->c00.dwval = *(csc_coeff);
   ccsc_dev[sel][ch_id]->c01.dwval = *(csc_coeff + 1);
   ccsc_dev[sel][ch_id]->c02.dwval = *(csc_coeff + 2);
   ccsc_dev[sel][ch_id]->c03.dwval = *(csc_coeff + 3) + 0x200;
   ccsc_dev[sel][ch_id]->c10.dwval = *(csc_coeff + 4);
   ccsc_dev[sel][ch_id]->c11.dwval = *(csc_coeff + 5);
   ccsc_dev[sel][ch_id]->c12.dwval = *(csc_coeff + 6);
   ccsc_dev[sel][ch_id]->c13.dwval = *(csc_coeff + 7) + 0x200;
   ccsc_dev[sel][ch_id]->c20.dwval = *(csc_coeff + 8);
   ccsc_dev[sel][ch_id]->c21.dwval = *(csc_coeff + 9);
   ccsc_dev[sel][ch_id]->c22.dwval = *(csc_coeff + 10);
   ccsc_dev[sel][ch_id]->c23.dwval = *(csc_coeff + 11) + 0x200;
 
   ccsc_dev[sel][ch_id]->bypass.bits.enable = 1;
   /* always enable csc */
   csc_block[sel][ch_id].dirty = 1;
 
   return 0;
}
 
int de_ccsc_update_regs(unsigned int sel)
{
   int ch_id;
   for (ch_id = 0; ch_id < vi_num[sel]; ch_id++) {
       if (csc_block[sel][ch_id].dirty == 0x1) {
           memcpy((void *)csc_block[sel][ch_id].off,
                  csc_block[sel][ch_id].val,
                  csc_block[sel][ch_id].size);
           csc_block[sel][ch_id].dirty = 0x0;
       }
       if (vep_support[sel][ch_id]) {
           if (icsc_block[sel][ch_id].dirty == 0x1) {
               memcpy((void *)icsc_block[sel][ch_id].off,
                      icsc_block[sel][ch_id].val,
                      icsc_block[sel][ch_id].size);
               icsc_block[sel][ch_id].dirty = 0x0;
           }
       }
   }
   return 0;
}
 
int de_ccsc_init(disp_bsp_init_para *para)
{
   uintptr_t base, base_ofst;
   void *memory;
   int screen_id, ch_id, device_num;
 
   device_num = de_feat_get_num_screens();
 
   for (screen_id = 0; screen_id < device_num; screen_id++)
       vi_num[screen_id] = de_feat_get_num_vi_chns(screen_id);
 
   for (screen_id = 0; screen_id < device_num; screen_id++)
       for (ch_id = 0; ch_id < vi_num[screen_id]; ch_id++) {
           vep_support[screen_id][ch_id] =
               de_feat_is_support_vep_by_chn(screen_id, ch_id);
 
           if (screen_id == 0) {
               base_ofst =
                   (ch_id == 0) ? CCSC00_OFST : CCSC01_OFST;
           } else {
               if (vep_support[screen_id][ch_id]) {
                   base_ofst = (ch_id == 0) ?
                       CCSC00_OFST : CCSC01_OFST;
               } else {
                   base_ofst = (ch_id == 0) ?
                       CCSC10_OFST : CCSC11_OFST;
               }
           }
 
#if defined(CONFIG_INDEPENDENT_DE)
           base = para->reg_base[DISP_MOD_DE + screen_id] + (screen_id + 1)
               * 0x00100000 + base_ofst;
           if (screen_id)
               base = base - 0x00100000;
#else
           base = para->reg_base[DISP_MOD_DE] + (screen_id + 1)
               * 0x00100000 + base_ofst;
#endif
           memory =
               kmalloc(sizeof(struct __csc_reg_t),
                       GFP_KERNEL | __GFP_ZERO);
           if (NULL == memory) {
               __wrn("alloc Ccsc[%d][%d] mm fail!size=0x%x\n",
                    screen_id, ch_id,
                    (unsigned int)sizeof(struct __csc_reg_t));
               return -1;
           }
 
           csc_block[screen_id][ch_id].off = base;
           csc_block[screen_id][ch_id].val = memory;
           csc_block[screen_id][ch_id].size = 0x40;
           csc_block[screen_id][ch_id].dirty = 0;
 
           de_ccsc_set_reg_base(screen_id, ch_id, memory);
 
           /* input csc */
           if (vep_support[screen_id][ch_id]) {
               base_ofst = (ch_id == 0) ?
                   ICSC0_OFST : ICSC1_OFST;
#if defined(CONFIG_INDEPENDENT_DE)
               base = para->reg_base[DISP_MOD_DE + screen_id] +
                   (screen_id + 1) * 0x00100000
                   + FCE_OFST + 0x40;
               if (screen_id)
                   base = base - 0x00100000;
#else
               base = para->reg_base[DISP_MOD_DE] +
                   (screen_id + 1) * 0x00100000
                   + FCE_OFST + 0x40;
#endif
               __inf("sel%d, Icsc_base[%d]=0x%p\n", screen_id,
                     ch_id, (void *)base);
 
               memory =
                   kmalloc(sizeof(struct __icsc_reg_t),
                           GFP_KERNEL | __GFP_ZERO);
 
               icsc_block[screen_id][ch_id].off = base;
               icsc_block[screen_id][ch_id].val = memory;
               icsc_block[screen_id][ch_id].size = 0x04;
               icsc_block[screen_id][ch_id].dirty = 0;
 
               de_icsc_set_reg_base(screen_id, ch_id, memory);
           }
 
       }
 
   return 0;
}
 
struct __scal_matrix4x4 {
   __s64 x00;
   __s64 x01;
   __s64 x02;
   __s64 x03;
   __s64 x10;
   __s64 x11;
   __s64 x12;
   __s64 x13;
   __s64 x20;
   __s64 x21;
   __s64 x22;
   __s64 x23;
   __s64 x30;
   __s64 x31;
   __s64 x32;
   __s64 x33;
};
 
inline int in_tright_shift(int datain, unsigned int shiftbit)
{
   int dataout;
   int tmp;
   tmp = (shiftbit >= 1) ? (1 << (shiftbit - 1)) : 0;
   if (datain >= 0)
       dataout = (datain + tmp) >> shiftbit;
   else
       dataout = -((-datain + tmp) >> shiftbit);
 
   return dataout;
}
 
inline __s64 IntRightShift64(__s64 datain, unsigned int shiftbit)
{
   __s64 dataout;
   __s64 tmp;
   tmp = (shiftbit >= 1) ? (1 << (shiftbit - 1)) : 0;
   if (datain >= 0)
       dataout = (datain + tmp) >> shiftbit;
   else
       dataout = -((-datain + tmp) >> shiftbit);
 
   return dataout;
}
 
static s32 IDE_SCAL_MATRIC_MUL(struct __scal_matrix4x4 *in1,
   struct __scal_matrix4x4 *in2, struct __scal_matrix4x4 *result)
{
 
   result->x00 =
       IntRightShift64(in1->x00 * in2->x00 + in1->x01 * in2->x10 +
               in1->x02 * in2->x20 + in1->x03 * in2->x30, 10);
   result->x01 =
       IntRightShift64(in1->x00 * in2->x01 + in1->x01 * in2->x11 +
               in1->x02 * in2->x21 + in1->x03 * in2->x31, 10);
   result->x02 =
       IntRightShift64(in1->x00 * in2->x02 + in1->x01 * in2->x12 +
               in1->x02 * in2->x22 + in1->x03 * in2->x32, 10);
   result->x03 =
       IntRightShift64(in1->x00 * in2->x03 + in1->x01 * in2->x13 +
               in1->x02 * in2->x23 + in1->x03 * in2->x33, 10);
   result->x10 =
       IntRightShift64(in1->x10 * in2->x00 + in1->x11 * in2->x10 +
               in1->x12 * in2->x20 + in1->x13 * in2->x30, 10);
   result->x11 =
       IntRightShift64(in1->x10 * in2->x01 + in1->x11 * in2->x11 +
               in1->x12 * in2->x21 + in1->x13 * in2->x31, 10);
   result->x12 =
       IntRightShift64(in1->x10 * in2->x02 + in1->x11 * in2->x12 +
               in1->x12 * in2->x22 + in1->x13 * in2->x32, 10);
   result->x13 =
       IntRightShift64(in1->x10 * in2->x03 + in1->x11 * in2->x13 +
               in1->x12 * in2->x23 + in1->x13 * in2->x33, 10);
   result->x20 =
       IntRightShift64(in1->x20 * in2->x00 + in1->x21 * in2->x10 +
               in1->x22 * in2->x20 + in1->x23 * in2->x30, 10);
   result->x21 =
       IntRightShift64(in1->x20 * in2->x01 + in1->x21 * in2->x11 +
               in1->x22 * in2->x21 + in1->x23 * in2->x31, 10);
   result->x22 =
       IntRightShift64(in1->x20 * in2->x02 + in1->x21 * in2->x12 +
               in1->x22 * in2->x22 + in1->x23 * in2->x32, 10);
   result->x23 =
       IntRightShift64(in1->x20 * in2->x03 + in1->x21 * in2->x13 +
               in1->x22 * in2->x23 + in1->x23 * in2->x33, 10);
   result->x30 =
       IntRightShift64(in1->x30 * in2->x00 + in1->x31 * in2->x10 +
               in1->x32 * in2->x20 + in1->x33 * in2->x30, 10);
   result->x31 =
       IntRightShift64(in1->x30 * in2->x01 + in1->x31 * in2->x11 +
               in1->x32 * in2->x21 + in1->x33 * in2->x31, 10);
   result->x32 =
       IntRightShift64(in1->x30 * in2->x02 + in1->x31 * in2->x12 +
               in1->x32 * in2->x22 + in1->x33 * in2->x32, 10);
   result->x33 =
       IntRightShift64(in1->x30 * in2->x03 + in1->x31 * in2->x13 +
               in1->x32 * in2->x23 + in1->x33 * in2->x33, 10);
 
   return 0;
}
 
/* normal case:
 *display a SD video:
 *infmt = DE_YUV, incscmod = BT_601, outfmt = DE_RGB
 *outcscmod = BT_601, out_color_range = DISP_COLOR_RANGE_0_255
 *display a HD video:
 *infmt = DE_YUV, incscmod = BT_709, outfmt = DE_RGB
 *outcscmod = BT_601, out_color_range = DISP_COLOR_RANGE_0_255
 *display a JPEG picture:
 *infmt = DE_YUV, incscmod = BT_YCC, outfmt = DE_RGB
 *outcscmod = BT_601, out_color_range = DISP_COLOR_RANGE_0_255
 *display a UI (RGB format)     with ENHANCE enable
 *infmt = DE_YUV, incscmod = BT_ENHANCE, outfmt = DE_RGB
 *outcscmod = BT_601, out_color_range = DISP_COLOR_RANGE_0_255
 *output to TV with HDMI in RGB mode:
 *infmt = DE_RGB, incscmod = BT_601, outfmt = DE_RGB
 *outcscmod = BT_601, out_color_range = DISP_COLOR_RANGE_16_235
 *output to PC with HDMI in RGB mode:
 *infmt = DE_RGB, incscmod = BT_601, outfmt = DE_RGB
 *outcscmod = BT_601, out_color_range = DISP_COLOR_RANGE_0_255
 *output to TV with HDMI in YCbCr mode, 480i/576i/480p/576p:
 *infmt = DE_RGB, incscmod = BT_601, outfmt = DE_YUV, outcscmod = BT_601
 *out_color_range = DISP_COLOR_RANGE_0_255
 *output to TV with HDMI in YCbCr mode, 720p/1080p/2160p:
 *infmt = DE_RGB, incscmod = BT_601, outfmt = DE_YUV
 *outcscmod = BT_709, out_color_range = DISP_COLOR_RANGE_0_255
 *output to TV with CVBS:
 *infmt = DE_RGB, incscmod = BT_601, outfmt = DE_YUV
 *outcscmod = BT_601, out_color_range = DISP_COLOR_RANGE_0_255
 *bypass:
 *outfmt = infmt, outcscmod = incscmod
 *out_color_range = DISP_COLOR_RANGE_0_255
 *brightness=contrast=saturation=hue=50
 */
int de_csc_coeff_calc(unsigned int infmt, unsigned int incscmod,
             unsigned int outfmt, unsigned int outcscmod,
             unsigned int brightness, unsigned int contrast,
             unsigned int saturation, unsigned int hue,
             unsigned int out_color_range, int *csc_coeff)
{
   struct __scal_matrix4x4 *enhancecoeff, *tmpcoeff;
   struct __scal_matrix4x4 *coeff[5], *in0coeff, *in1coeff;
   int oper, i;
   int i_bright, i_contrast, i_saturation, i_hue, sinv, cosv;
 
   oper = 0;
 
   enhancecoeff = kmalloc(sizeof(struct __scal_matrix4x4),
           GFP_KERNEL | __GFP_ZERO);
   tmpcoeff = kmalloc(sizeof(struct __scal_matrix4x4),
       GFP_KERNEL | __GFP_ZERO);
   in0coeff = kmalloc(sizeof(struct __scal_matrix4x4),
       GFP_KERNEL | __GFP_ZERO);
 
   if (!enhancecoeff || !tmpcoeff || !in0coeff) {
       __wrn("kmalloc fail!\n");
       goto err;
   }
   /* BYPASS */
   if (infmt == outfmt && incscmod == outcscmod
       && out_color_range == DISP_COLOR_RANGE_0_255 && brightness == 50
       && contrast == 50 && saturation == 50 && hue == 50) {
       memcpy(csc_coeff, bypass_csc, 48);
       goto err;
   }
   /* NON-BYPASS */
   if (infmt == DE_RGB) {
       /* convert to YCbCr */
       if (outfmt == DE_RGB) {
           coeff[oper] = (struct __scal_matrix4x4 *) (r2y + 0x20);
           oper++;
       } else {
           if (outcscmod == DE_BT601) {
               coeff[oper] = (struct __scal_matrix4x4 *) (r2y);
               oper++;
           } else if (outcscmod == DE_BT709) {
               coeff[oper] = (struct __scal_matrix4x4 *)
                   (r2y + 0x20);
               oper++;
           }
       }
   } else {
       if (incscmod != outcscmod && outfmt == DE_YUV) {
           if (incscmod == DE_BT601 && outcscmod == DE_BT709) {
               coeff[oper] = (struct __scal_matrix4x4 *) (y2y);
               oper++;
           } else if (incscmod == DE_BT709
                  && outcscmod == DE_BT601) {
               coeff[oper] = (struct __scal_matrix4x4 *)
                   (y2y + 0x20);
               oper++;
           }
       }
   }
 
   if (brightness != 50 || contrast != 50
       || saturation != 50 || hue != 50) {
       brightness = brightness > 100 ? 100 : brightness;
       contrast = contrast > 100 ? 100 : contrast;
       saturation = saturation > 100 ? 100 : saturation;
       hue = hue > 100 ? 100 : hue;
 
       i_bright = (int)(brightness * 64 / 100);
       i_saturation = (int)(saturation * 64 / 100);
       i_contrast = (int)(contrast * 64 / 100);
       i_hue = (int)(hue * 64 / 100);
 
       sinv = sin_cos[i_hue & 0x3f];
       cosv = sin_cos[64 + (i_hue & 0x3f)];
 
       /* calculate enhance matrix */
       enhancecoeff->x00 = i_contrast << 7;
       enhancecoeff->x01 = 0;
       enhancecoeff->x02 = 0;
       enhancecoeff->x03 =
           (((i_bright - 32) + 16) << 12) - (i_contrast << 11);
       enhancecoeff->x10 = 0;
       enhancecoeff->x11 = (i_contrast * i_saturation * cosv) >> 5;
       enhancecoeff->x12 = (i_contrast * i_saturation * sinv) >> 5;
       enhancecoeff->x13 =
           (1 << 19) - ((enhancecoeff->x11 + enhancecoeff->x12) << 7);
       enhancecoeff->x20 = 0;
       enhancecoeff->x21 = (-i_contrast * i_saturation * sinv) >> 5;
       enhancecoeff->x22 = (i_contrast * i_saturation * cosv) >> 5;
       enhancecoeff->x23 =
           (1 << 19) - ((enhancecoeff->x22 + enhancecoeff->x21) << 7);
       enhancecoeff->x30 = 0;
       enhancecoeff->x31 = 0;
       enhancecoeff->x32 = 0;
       enhancecoeff->x33 = 4096;
 
       coeff[oper] = enhancecoeff;
       oper++;
 
   }
 
   if (outfmt == DE_RGB) {
       if (infmt == DE_RGB) {
           coeff[oper] = (struct __scal_matrix4x4 *) (y2r + 0x20);
           oper++;
 
           if (out_color_range == DISP_COLOR_RANGE_16_235) {
               coeff[oper] = (struct __scal_matrix4x4 *) (r2r);
               oper++;
           }
       } else {
           if (out_color_range == DISP_COLOR_RANGE_16_235) {
               if (incscmod == DE_BT601) {
                   coeff[oper] =
                       (struct __scal_matrix4x4 *)
                       (y2r + 0x80);
                   oper++;
               } else if (incscmod == DE_BT709) {
                   coeff[oper] =
                       (struct __scal_matrix4x4 *)
                       (y2r + 0xa0);
                   oper++;
               }
           } else {
               if (incscmod == DE_BT601) {
                   coeff[oper] =
                       (struct __scal_matrix4x4 *) (y2r);
                   oper++;
               } else if (incscmod == DE_BT709) {
                   coeff[oper] =
                       (struct __scal_matrix4x4 *)
                       (y2r + 0x20);
                   oper++;
               } else if (incscmod == DE_YCC) {
                   coeff[oper] =
                       (struct __scal_matrix4x4 *)
                       (y2r + 0x40);
                   oper++;
               } else if (incscmod == DE_ENHANCE) {
                   coeff[oper] =
                       (struct __scal_matrix4x4 *)
                       (y2r + 0x60);
                   oper++;
               }
           }
       }
   }
   /* matrix multiply */
   if (oper == 0) {
       csc_coeff = bypass_csc;
   } else if (oper == 1) {
       for (i = 0; i < 12; i++)
           *(csc_coeff + i) =
               IntRightShift64((int)(*((__s64 *) coeff[0] + i)),
                       oper << 1);
   } else {
       memcpy((void *)in0coeff, (void *)coeff[0],
           sizeof(struct __scal_matrix4x4));
       for (i = 1; i < oper; i++) {
           in1coeff = coeff[i];
           IDE_SCAL_MATRIC_MUL(in1coeff, in0coeff, tmpcoeff);
           memcpy((void *)in0coeff, (void *)tmpcoeff,
               sizeof(struct __scal_matrix4x4));
       }
 
       for (i = 0; i < 12; i++)
           *(csc_coeff + i) =
               IntRightShift64((int)(*((__s64 *) tmpcoeff + i)),
                       oper << 1);
   }
 
err:
   kfree(in0coeff);
   kfree(tmpcoeff);
   kfree(enhancecoeff);
 
   return 0;
 
}