]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/video/omap2/dss/dss.h
OMAPDSS: Use only "omapdss_dss" platform device to get context lost count
[karo-tx-linux.git] / drivers / video / omap2 / dss / dss.h
1 /*
2  * linux/drivers/video/omap2/dss/dss.h
3  *
4  * Copyright (C) 2009 Nokia Corporation
5  * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
6  *
7  * Some code and ideas taken from drivers/video/omap/ driver
8  * by Imre Deak.
9  *
10  * This program is free software; you can redistribute it and/or modify it
11  * under the terms of the GNU General Public License version 2 as published by
12  * the Free Software Foundation.
13  *
14  * This program is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
17  * more details.
18  *
19  * You should have received a copy of the GNU General Public License along with
20  * this program.  If not, see <http://www.gnu.org/licenses/>.
21  */
22
23 #ifndef __OMAP2_DSS_H
24 #define __OMAP2_DSS_H
25
26 #ifdef pr_fmt
27 #undef pr_fmt
28 #endif
29
30 #ifdef DSS_SUBSYS_NAME
31 #define pr_fmt(fmt) DSS_SUBSYS_NAME ": " fmt
32 #else
33 #define pr_fmt(fmt) fmt
34 #endif
35
36 #define DSSDBG(format, ...) \
37         pr_debug(format, ## __VA_ARGS__)
38
39 #ifdef DSS_SUBSYS_NAME
40 #define DSSERR(format, ...) \
41         printk(KERN_ERR "omapdss " DSS_SUBSYS_NAME " error: " format, \
42         ## __VA_ARGS__)
43 #else
44 #define DSSERR(format, ...) \
45         printk(KERN_ERR "omapdss error: " format, ## __VA_ARGS__)
46 #endif
47
48 #ifdef DSS_SUBSYS_NAME
49 #define DSSINFO(format, ...) \
50         printk(KERN_INFO "omapdss " DSS_SUBSYS_NAME ": " format, \
51         ## __VA_ARGS__)
52 #else
53 #define DSSINFO(format, ...) \
54         printk(KERN_INFO "omapdss: " format, ## __VA_ARGS__)
55 #endif
56
57 #ifdef DSS_SUBSYS_NAME
58 #define DSSWARN(format, ...) \
59         printk(KERN_WARNING "omapdss " DSS_SUBSYS_NAME ": " format, \
60         ## __VA_ARGS__)
61 #else
62 #define DSSWARN(format, ...) \
63         printk(KERN_WARNING "omapdss: " format, ## __VA_ARGS__)
64 #endif
65
66 /* OMAP TRM gives bitfields as start:end, where start is the higher bit
67    number. For example 7:0 */
68 #define FLD_MASK(start, end)    (((1 << ((start) - (end) + 1)) - 1) << (end))
69 #define FLD_VAL(val, start, end) (((val) << (end)) & FLD_MASK(start, end))
70 #define FLD_GET(val, start, end) (((val) & FLD_MASK(start, end)) >> (end))
71 #define FLD_MOD(orig, val, start, end) \
72         (((orig) & ~FLD_MASK(start, end)) | FLD_VAL(val, start, end))
73
74 enum dss_io_pad_mode {
75         DSS_IO_PAD_MODE_RESET,
76         DSS_IO_PAD_MODE_RFBI,
77         DSS_IO_PAD_MODE_BYPASS,
78 };
79
80 enum dss_hdmi_venc_clk_source_select {
81         DSS_VENC_TV_CLK = 0,
82         DSS_HDMI_M_PCLK = 1,
83 };
84
85 enum dss_dsi_content_type {
86         DSS_DSI_CONTENT_DCS,
87         DSS_DSI_CONTENT_GENERIC,
88 };
89
90 enum dss_writeback_channel {
91         DSS_WB_LCD1_MGR =       0,
92         DSS_WB_LCD2_MGR =       1,
93         DSS_WB_TV_MGR =         2,
94         DSS_WB_OVL0 =           3,
95         DSS_WB_OVL1 =           4,
96         DSS_WB_OVL2 =           5,
97         DSS_WB_OVL3 =           6,
98         DSS_WB_LCD3_MGR =       7,
99 };
100
101 struct dss_clock_info {
102         /* rates that we get with dividers below */
103         unsigned long fck;
104
105         /* dividers */
106         u16 fck_div;
107 };
108
109 struct dispc_clock_info {
110         /* rates that we get with dividers below */
111         unsigned long lck;
112         unsigned long pck;
113
114         /* dividers */
115         u16 lck_div;
116         u16 pck_div;
117 };
118
119 struct dsi_clock_info {
120         /* rates that we get with dividers below */
121         unsigned long fint;
122         unsigned long clkin4ddr;
123         unsigned long clkin;
124         unsigned long dsi_pll_hsdiv_dispc_clk;  /* OMAP3: DSI1_PLL_CLK
125                                                  * OMAP4: PLLx_CLK1 */
126         unsigned long dsi_pll_hsdiv_dsi_clk;    /* OMAP3: DSI2_PLL_CLK
127                                                  * OMAP4: PLLx_CLK2 */
128         unsigned long lp_clk;
129
130         /* dividers */
131         u16 regn;
132         u16 regm;
133         u16 regm_dispc; /* OMAP3: REGM3
134                          * OMAP4: REGM4 */
135         u16 regm_dsi;   /* OMAP3: REGM4
136                          * OMAP4: REGM5 */
137         u16 lp_clk_div;
138 };
139
140 struct reg_field {
141         u16 reg;
142         u8 high;
143         u8 low;
144 };
145
146 struct dss_lcd_mgr_config {
147         enum dss_io_pad_mode io_pad_mode;
148
149         bool stallmode;
150         bool fifohandcheck;
151
152         struct dispc_clock_info clock_info;
153
154         int video_port_width;
155
156         int lcden_sig_polarity;
157 };
158
159 struct seq_file;
160 struct platform_device;
161
162 /* core */
163 struct platform_device *dss_get_core_pdev(void);
164 struct bus_type *dss_get_bus(void);
165 struct regulator *dss_get_vdds_dsi(void);
166 struct regulator *dss_get_vdds_sdi(void);
167 int dss_dsi_enable_pads(int dsi_id, unsigned lane_mask);
168 void dss_dsi_disable_pads(int dsi_id, unsigned lane_mask);
169 int dss_set_min_bus_tput(struct device *dev, unsigned long tput);
170 int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *));
171
172 struct omap_dss_device *dss_alloc_and_init_device(struct device *parent);
173 int dss_add_device(struct omap_dss_device *dssdev);
174 void dss_unregister_device(struct omap_dss_device *dssdev);
175 void dss_unregister_child_devices(struct device *parent);
176 void dss_put_device(struct omap_dss_device *dssdev);
177 void dss_copy_device_pdata(struct omap_dss_device *dst,
178                 const struct omap_dss_device *src);
179
180 /* apply */
181 void dss_apply_init(void);
182 int dss_mgr_wait_for_go(struct omap_overlay_manager *mgr);
183 int dss_mgr_wait_for_go_ovl(struct omap_overlay *ovl);
184 void dss_mgr_start_update(struct omap_overlay_manager *mgr);
185 int omap_dss_mgr_apply(struct omap_overlay_manager *mgr);
186
187 int dss_mgr_enable(struct omap_overlay_manager *mgr);
188 void dss_mgr_disable(struct omap_overlay_manager *mgr);
189 int dss_mgr_set_info(struct omap_overlay_manager *mgr,
190                 struct omap_overlay_manager_info *info);
191 void dss_mgr_get_info(struct omap_overlay_manager *mgr,
192                 struct omap_overlay_manager_info *info);
193 int dss_mgr_set_output(struct omap_overlay_manager *mgr,
194                 struct omap_dss_output *output);
195 int dss_mgr_unset_output(struct omap_overlay_manager *mgr);
196 void dss_mgr_set_timings(struct omap_overlay_manager *mgr,
197                 const struct omap_video_timings *timings);
198 void dss_mgr_set_lcd_config(struct omap_overlay_manager *mgr,
199                 const struct dss_lcd_mgr_config *config);
200
201 bool dss_ovl_is_enabled(struct omap_overlay *ovl);
202 int dss_ovl_enable(struct omap_overlay *ovl);
203 int dss_ovl_disable(struct omap_overlay *ovl);
204 int dss_ovl_set_info(struct omap_overlay *ovl,
205                 struct omap_overlay_info *info);
206 void dss_ovl_get_info(struct omap_overlay *ovl,
207                 struct omap_overlay_info *info);
208 int dss_ovl_set_manager(struct omap_overlay *ovl,
209                 struct omap_overlay_manager *mgr);
210 int dss_ovl_unset_manager(struct omap_overlay *ovl);
211
212 /* output */
213 void dss_register_output(struct omap_dss_output *out);
214 void dss_unregister_output(struct omap_dss_output *out);
215 struct omap_dss_output *omapdss_get_output_from_dssdev(struct omap_dss_device *dssdev);
216
217 /* display */
218 int dss_suspend_all_devices(void);
219 int dss_resume_all_devices(void);
220 void dss_disable_all_devices(void);
221
222 int dss_init_device(struct platform_device *pdev,
223                 struct omap_dss_device *dssdev);
224 void dss_uninit_device(struct platform_device *pdev,
225                 struct omap_dss_device *dssdev);
226
227 int display_init_sysfs(struct platform_device *pdev,
228                 struct omap_dss_device *dssdev);
229 void display_uninit_sysfs(struct platform_device *pdev,
230                 struct omap_dss_device *dssdev);
231
232 /* manager */
233 int dss_init_overlay_managers(struct platform_device *pdev);
234 void dss_uninit_overlay_managers(struct platform_device *pdev);
235 int dss_mgr_simple_check(struct omap_overlay_manager *mgr,
236                 const struct omap_overlay_manager_info *info);
237 int dss_mgr_check_timings(struct omap_overlay_manager *mgr,
238                 const struct omap_video_timings *timings);
239 int dss_mgr_check(struct omap_overlay_manager *mgr,
240                 struct omap_overlay_manager_info *info,
241                 const struct omap_video_timings *mgr_timings,
242                 const struct dss_lcd_mgr_config *config,
243                 struct omap_overlay_info **overlay_infos);
244
245 static inline bool dss_mgr_is_lcd(enum omap_channel id)
246 {
247         if (id == OMAP_DSS_CHANNEL_LCD || id == OMAP_DSS_CHANNEL_LCD2 ||
248                         id == OMAP_DSS_CHANNEL_LCD3)
249                 return true;
250         else
251                 return false;
252 }
253
254 int dss_manager_kobj_init(struct omap_overlay_manager *mgr,
255                 struct platform_device *pdev);
256 void dss_manager_kobj_uninit(struct omap_overlay_manager *mgr);
257
258 /* overlay */
259 void dss_init_overlays(struct platform_device *pdev);
260 void dss_uninit_overlays(struct platform_device *pdev);
261 void dss_overlay_setup_dispc_manager(struct omap_overlay_manager *mgr);
262 int dss_ovl_simple_check(struct omap_overlay *ovl,
263                 const struct omap_overlay_info *info);
264 int dss_ovl_check(struct omap_overlay *ovl, struct omap_overlay_info *info,
265                 const struct omap_video_timings *mgr_timings);
266 bool dss_ovl_use_replication(struct dss_lcd_mgr_config config,
267                 enum omap_color_mode mode);
268 int dss_overlay_kobj_init(struct omap_overlay *ovl,
269                 struct platform_device *pdev);
270 void dss_overlay_kobj_uninit(struct omap_overlay *ovl);
271
272 /* DSS */
273 int dss_init_platform_driver(void) __init;
274 void dss_uninit_platform_driver(void);
275
276 int dss_dpi_select_source(enum omap_channel channel);
277 void dss_select_hdmi_venc_clk_source(enum dss_hdmi_venc_clk_source_select);
278 enum dss_hdmi_venc_clk_source_select dss_get_hdmi_venc_clk_source(void);
279 const char *dss_get_generic_clk_source_name(enum omap_dss_clk_source clk_src);
280 void dss_dump_clocks(struct seq_file *s);
281
282 #if defined(CONFIG_OMAP2_DSS_DEBUGFS)
283 void dss_debug_dump_clocks(struct seq_file *s);
284 #endif
285
286 int dss_get_ctx_loss_count(void);
287
288 void dss_sdi_init(int datapairs);
289 int dss_sdi_enable(void);
290 void dss_sdi_disable(void);
291
292 void dss_select_dsi_clk_source(int dsi_module,
293                 enum omap_dss_clk_source clk_src);
294 void dss_select_lcd_clk_source(enum omap_channel channel,
295                 enum omap_dss_clk_source clk_src);
296 enum omap_dss_clk_source dss_get_dispc_clk_source(void);
297 enum omap_dss_clk_source dss_get_dsi_clk_source(int dsi_module);
298 enum omap_dss_clk_source dss_get_lcd_clk_source(enum omap_channel channel);
299
300 void dss_set_venc_output(enum omap_dss_venc_type type);
301 void dss_set_dac_pwrdn_bgz(bool enable);
302
303 unsigned long dss_get_dpll4_rate(void);
304 int dss_calc_clock_rates(struct dss_clock_info *cinfo);
305 int dss_set_clock_div(struct dss_clock_info *cinfo);
306 int dss_calc_clock_div(unsigned long req_pck, struct dss_clock_info *dss_cinfo,
307                 struct dispc_clock_info *dispc_cinfo);
308
309 /* SDI */
310 int sdi_init_platform_driver(void) __init;
311 void sdi_uninit_platform_driver(void) __exit;
312
313 /* DSI */
314 #ifdef CONFIG_OMAP2_DSS_DSI
315
316 struct dentry;
317 struct file_operations;
318
319 int dsi_init_platform_driver(void) __init;
320 void dsi_uninit_platform_driver(void) __exit;
321
322 int dsi_runtime_get(struct platform_device *dsidev);
323 void dsi_runtime_put(struct platform_device *dsidev);
324
325 void dsi_dump_clocks(struct seq_file *s);
326
327 void dsi_irq_handler(void);
328 u8 dsi_get_pixel_size(enum omap_dss_dsi_pixel_format fmt);
329
330 unsigned long dsi_get_pll_hsdiv_dispc_rate(struct platform_device *dsidev);
331 int dsi_pll_set_clock_div(struct platform_device *dsidev,
332                 struct dsi_clock_info *cinfo);
333 int dsi_pll_calc_clock_div_pck(struct platform_device *dsidev,
334                 unsigned long req_pck, struct dsi_clock_info *cinfo,
335                 struct dispc_clock_info *dispc_cinfo);
336 int dsi_pll_init(struct platform_device *dsidev, bool enable_hsclk,
337                 bool enable_hsdiv);
338 void dsi_pll_uninit(struct platform_device *dsidev, bool disconnect_lanes);
339 void dsi_wait_pll_hsdiv_dispc_active(struct platform_device *dsidev);
340 void dsi_wait_pll_hsdiv_dsi_active(struct platform_device *dsidev);
341 struct platform_device *dsi_get_dsidev_from_id(int module);
342 #else
343 static inline int dsi_runtime_get(struct platform_device *dsidev)
344 {
345         return 0;
346 }
347 static inline void dsi_runtime_put(struct platform_device *dsidev)
348 {
349 }
350 static inline u8 dsi_get_pixel_size(enum omap_dss_dsi_pixel_format fmt)
351 {
352         WARN("%s: DSI not compiled in, returning pixel_size as 0\n", __func__);
353         return 0;
354 }
355 static inline unsigned long dsi_get_pll_hsdiv_dispc_rate(struct platform_device *dsidev)
356 {
357         WARN("%s: DSI not compiled in, returning rate as 0\n", __func__);
358         return 0;
359 }
360 static inline int dsi_pll_set_clock_div(struct platform_device *dsidev,
361                 struct dsi_clock_info *cinfo)
362 {
363         WARN("%s: DSI not compiled in\n", __func__);
364         return -ENODEV;
365 }
366 static inline int dsi_pll_calc_clock_div_pck(struct platform_device *dsidev,
367                 unsigned long req_pck,
368                 struct dsi_clock_info *dsi_cinfo,
369                 struct dispc_clock_info *dispc_cinfo)
370 {
371         WARN("%s: DSI not compiled in\n", __func__);
372         return -ENODEV;
373 }
374 static inline int dsi_pll_init(struct platform_device *dsidev,
375                 bool enable_hsclk, bool enable_hsdiv)
376 {
377         WARN("%s: DSI not compiled in\n", __func__);
378         return -ENODEV;
379 }
380 static inline void dsi_pll_uninit(struct platform_device *dsidev,
381                 bool disconnect_lanes)
382 {
383 }
384 static inline void dsi_wait_pll_hsdiv_dispc_active(struct platform_device *dsidev)
385 {
386 }
387 static inline void dsi_wait_pll_hsdiv_dsi_active(struct platform_device *dsidev)
388 {
389 }
390 static inline struct platform_device *dsi_get_dsidev_from_id(int module)
391 {
392         return NULL;
393 }
394 #endif
395
396 /* DPI */
397 int dpi_init_platform_driver(void) __init;
398 void dpi_uninit_platform_driver(void) __exit;
399
400 /* DISPC */
401 int dispc_init_platform_driver(void) __init;
402 void dispc_uninit_platform_driver(void) __exit;
403 void dispc_dump_clocks(struct seq_file *s);
404 u32 dispc_read_irqstatus(void);
405 void dispc_clear_irqstatus(u32 mask);
406 u32 dispc_read_irqenable(void);
407 void dispc_write_irqenable(u32 mask);
408
409 int dispc_runtime_get(void);
410 void dispc_runtime_put(void);
411
412 void dispc_enable_sidle(void);
413 void dispc_disable_sidle(void);
414
415 void dispc_lcd_enable_signal(bool enable);
416 void dispc_pck_free_enable(bool enable);
417 void dispc_enable_fifomerge(bool enable);
418 void dispc_enable_gamma_table(bool enable);
419 void dispc_set_loadmode(enum omap_dss_load_mode mode);
420
421 bool dispc_mgr_timings_ok(enum omap_channel channel,
422                 const struct omap_video_timings *timings);
423 unsigned long dispc_fclk_rate(void);
424 void dispc_find_clk_divs(unsigned long req_pck, unsigned long fck,
425                 struct dispc_clock_info *cinfo);
426 int dispc_calc_clock_rates(unsigned long dispc_fclk_rate,
427                 struct dispc_clock_info *cinfo);
428
429
430 void dispc_ovl_set_fifo_threshold(enum omap_plane plane, u32 low, u32 high);
431 void dispc_ovl_compute_fifo_thresholds(enum omap_plane plane,
432                 u32 *fifo_low, u32 *fifo_high, bool use_fifomerge,
433                 bool manual_update);
434 int dispc_ovl_setup(enum omap_plane plane, const struct omap_overlay_info *oi,
435                 bool replication, const struct omap_video_timings *mgr_timings,
436                 bool mem_to_mem);
437 int dispc_ovl_enable(enum omap_plane plane, bool enable);
438 bool dispc_ovl_enabled(enum omap_plane plane);
439 void dispc_ovl_set_channel_out(enum omap_plane plane,
440                 enum omap_channel channel);
441
442 u32 dispc_mgr_get_vsync_irq(enum omap_channel channel);
443 u32 dispc_mgr_get_framedone_irq(enum omap_channel channel);
444 u32 dispc_mgr_get_sync_lost_irq(enum omap_channel channel);
445 bool dispc_mgr_go_busy(enum omap_channel channel);
446 void dispc_mgr_go(enum omap_channel channel);
447 void dispc_mgr_enable(enum omap_channel channel, bool enable);
448 bool dispc_mgr_is_enabled(enum omap_channel channel);
449 void dispc_mgr_enable_sync(enum omap_channel channel);
450 void dispc_mgr_disable_sync(enum omap_channel channel);
451 void dispc_mgr_set_lcd_config(enum omap_channel channel,
452                 const struct dss_lcd_mgr_config *config);
453 void dispc_mgr_set_timings(enum omap_channel channel,
454                 const struct omap_video_timings *timings);
455 unsigned long dispc_mgr_lclk_rate(enum omap_channel channel);
456 unsigned long dispc_mgr_pclk_rate(enum omap_channel channel);
457 unsigned long dispc_core_clk_rate(void);
458 void dispc_mgr_set_clock_div(enum omap_channel channel,
459                 const struct dispc_clock_info *cinfo);
460 int dispc_mgr_get_clock_div(enum omap_channel channel,
461                 struct dispc_clock_info *cinfo);
462 void dispc_mgr_setup(enum omap_channel channel,
463                 const struct omap_overlay_manager_info *info);
464
465 u32 dispc_wb_get_framedone_irq(void);
466 bool dispc_wb_go_busy(void);
467 void dispc_wb_go(void);
468 void dispc_wb_enable(bool enable);
469 bool dispc_wb_is_enabled(void);
470 void dispc_wb_set_channel_in(enum dss_writeback_channel channel);
471 int dispc_wb_setup(const struct omap_dss_writeback_info *wi,
472                 bool mem_to_mem, const struct omap_video_timings *timings);
473
474 /* VENC */
475 #ifdef CONFIG_OMAP2_DSS_VENC
476 int venc_init_platform_driver(void) __init;
477 void venc_uninit_platform_driver(void) __exit;
478 unsigned long venc_get_pixel_clock(void);
479 #else
480 static inline unsigned long venc_get_pixel_clock(void)
481 {
482         WARN("%s: VENC not compiled in, returning pclk as 0\n", __func__);
483         return 0;
484 }
485 #endif
486 int omapdss_venc_display_enable(struct omap_dss_device *dssdev);
487 void omapdss_venc_display_disable(struct omap_dss_device *dssdev);
488 void omapdss_venc_set_timings(struct omap_dss_device *dssdev,
489                 struct omap_video_timings *timings);
490 int omapdss_venc_check_timings(struct omap_dss_device *dssdev,
491                 struct omap_video_timings *timings);
492 u32 omapdss_venc_get_wss(struct omap_dss_device *dssdev);
493 int omapdss_venc_set_wss(struct omap_dss_device *dssdev, u32 wss);
494 void omapdss_venc_set_type(struct omap_dss_device *dssdev,
495                 enum omap_dss_venc_type type);
496 void omapdss_venc_invert_vid_out_polarity(struct omap_dss_device *dssdev,
497                 bool invert_polarity);
498 int venc_panel_init(void);
499 void venc_panel_exit(void);
500
501 /* HDMI */
502 #ifdef CONFIG_OMAP4_DSS_HDMI
503 int hdmi_init_platform_driver(void) __init;
504 void hdmi_uninit_platform_driver(void) __exit;
505 unsigned long hdmi_get_pixel_clock(void);
506 #else
507 static inline unsigned long hdmi_get_pixel_clock(void)
508 {
509         WARN("%s: HDMI not compiled in, returning pclk as 0\n", __func__);
510         return 0;
511 }
512 #endif
513 int omapdss_hdmi_display_enable(struct omap_dss_device *dssdev);
514 void omapdss_hdmi_display_disable(struct omap_dss_device *dssdev);
515 int omapdss_hdmi_core_enable(struct omap_dss_device *dssdev);
516 void omapdss_hdmi_core_disable(struct omap_dss_device *dssdev);
517 void omapdss_hdmi_display_set_timing(struct omap_dss_device *dssdev,
518                 struct omap_video_timings *timings);
519 int omapdss_hdmi_display_check_timing(struct omap_dss_device *dssdev,
520                                         struct omap_video_timings *timings);
521 int omapdss_hdmi_read_edid(u8 *buf, int len);
522 bool omapdss_hdmi_detect(void);
523 int hdmi_panel_init(void);
524 void hdmi_panel_exit(void);
525 #ifdef CONFIG_OMAP4_DSS_HDMI_AUDIO
526 int hdmi_audio_enable(void);
527 void hdmi_audio_disable(void);
528 int hdmi_audio_start(void);
529 void hdmi_audio_stop(void);
530 bool hdmi_mode_has_audio(void);
531 int hdmi_audio_config(struct omap_dss_audio *audio);
532 #endif
533
534 /* RFBI */
535 int rfbi_init_platform_driver(void) __init;
536 void rfbi_uninit_platform_driver(void) __exit;
537
538
539 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
540 static inline void dss_collect_irq_stats(u32 irqstatus, unsigned *irq_arr)
541 {
542         int b;
543         for (b = 0; b < 32; ++b) {
544                 if (irqstatus & (1 << b))
545                         irq_arr[b]++;
546         }
547 }
548 #endif
549
550 #endif