Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

V4L/DVB: sh_mobile_ceu_camera.c: update documentation to reflect the new cropping

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Guennadi Liakhovetski and committed by
Mauro Carvalho Chehab
f7fc97ad ab56d5eb

+31 -49
+31 -49
Documentation/video4linux/sh_mobile_ceu_camera.txt
··· 17 17 -2-- -\ 18 18 | --\ 19 19 | --\ 20 - +-5-- -\ -- -3-- 21 - | ---\ 22 - | --- -4-- -\ 23 - | -\ 24 - | - -6-- 20 + +-5-- . -- -3-- -\ 21 + | `... -\ 22 + | `... -4-- . - -7.. 23 + | `. 24 + | `. .6-- 25 25 | 26 - | - -6'- 27 - | -/ 28 - | --- -4'- -/ 29 - | ---/ 30 - +-5'- -/ 31 - | -- -3'- 26 + | . .6'- 27 + | .´ 28 + | ... -4'- .´ 29 + | ...´ - -7'. 30 + +-5'- .´ -/ 31 + | -- -3'- -/ 32 32 | --/ 33 33 | --/ 34 34 -2'- -/ ··· 36 36 | 37 37 -1'- 38 38 39 - Produced by user requests: 39 + In the above chart minuses and slashes represent "real" data amounts, points and 40 + accents represent "useful" data, basically, CEU scaled amd cropped output, 41 + mapped back onto the client's source plane. 42 + 43 + Such a configuration can be produced by user requests: 40 44 41 45 S_CROP(left / top = (5) - (1), width / height = (5') - (5)) 42 46 S_FMT(width / height = (6') - (6)) ··· 110 106 S_CROP 111 107 ------ 112 108 113 - If old scale applied to new crop is invalid produce nearest new scale possible 109 + The API at http://v4l2spec.bytesex.org/spec/x1904.htm says: 114 110 115 - 1. Calculate current combined scales. 111 + "...specification does not define an origin or units. However by convention 112 + drivers should horizontally count unscaled samples relative to 0H." 116 113 117 - scale_comb = (((4') - (4)) / ((6') - (6))) * (((2') - (2)) / ((3') - (3))) 114 + We choose to follow the advise and interpret cropping units as client input 115 + pixels. 118 116 119 - 2. Apply iterative sensor S_CROP for new input window. 117 + Cropping is performed in the following 6 steps: 120 118 121 - 3. If old combined scales applied to new crop produce an impossible user window, 122 - adjust scales to produce nearest possible window. 119 + 1. Request exactly user rectangle from the sensor. 123 120 124 - width_u_out = ((5') - (5)) / scale_comb 121 + 2. If smaller - iterate until a larger one is obtained. Result: sensor cropped 122 + to 2 : 2', target crop 5 : 5', current output format 6' - 6. 125 123 126 - if (width_u_out > max) 127 - scale_comb = ((5') - (5)) / max; 128 - else if (width_u_out < min) 129 - scale_comb = ((5') - (5)) / min; 124 + 3. In the previous step the sensor has tried to preserve its output frame as 125 + good as possible, but it could have changed. Retrieve it again. 130 126 131 - 4. Issue G_CROP to retrieve actual input window. 127 + 4. Sensor scaled to 3 : 3'. Sensor's scale is (2' - 2) / (3' - 3). Calculate 128 + intermediate window: 4' - 4 = (5' - 5) * (3' - 3) / (2' - 2) 132 129 133 - 5. Using actual input window and calculated combined scales calculate sensor 134 - target output window. 130 + 5. Calculate and apply host scale = (6' - 6) / (4' - 4) 135 131 136 - width_s_out = ((3') - (3)) = ((2') - (2)) / scale_comb 137 - 138 - 6. Apply iterative S_FMT for new sensor target output window. 139 - 140 - 7. Issue G_FMT to retrieve the actual sensor output window. 141 - 142 - 8. Calculate sensor scales. 143 - 144 - scale_s = ((3') - (3)) / ((2') - (2)) 145 - 146 - 9. Calculate sensor output subwindow to be cropped on CEU by applying sensor 147 - scales to the requested window. 148 - 149 - width_ceu = ((5') - (5)) / scale_s 150 - 151 - 10. Use CEU cropping for above calculated window. 152 - 153 - 11. Calculate CEU scales from sensor scales from results of (10) and user window 154 - from (3) 155 - 156 - scale_ceu = calc_scale(((5') - (5)), &width_u_out) 157 - 158 - 12. Apply CEU scales. 132 + 6. Calculate and apply host crop: 6 - 7 = (5 - 2) * (6' - 6) / (5' - 5) 159 133 160 134 -- 161 135 Author: Guennadi Liakhovetski <g.liakhovetski@gmx.de>