1
2
3
4
5
6
7
8
9
10#include "qemu/osdep.h"
11#include "hw/i2c/i2c.h"
12#include "migration/vmstate.h"
13#include "qemu/module.h"
14#include "hw/audio/wm8750.h"
15#include "audio/audio.h"
16
17#define IN_PORT_N 3
18#define OUT_PORT_N 3
19
20#define CODEC "wm8750"
21
22typedef struct {
23 int adc;
24 int adc_hz;
25 int dac;
26 int dac_hz;
27} WMRate;
28
29#define WM8750(obj) OBJECT_CHECK(WM8750State, (obj), TYPE_WM8750)
30
31typedef struct WM8750State {
32 I2CSlave parent_obj;
33
34 uint8_t i2c_data[2];
35 int i2c_len;
36 QEMUSoundCard card;
37 SWVoiceIn *adc_voice[IN_PORT_N];
38 SWVoiceOut *dac_voice[OUT_PORT_N];
39 int enable;
40 void (*data_req)(void *, int, int);
41 void *opaque;
42 uint8_t data_in[4096];
43 uint8_t data_out[4096];
44 int idx_in, req_in;
45 int idx_out, req_out;
46
47 SWVoiceOut **out[2];
48 uint8_t outvol[7], outmute[2];
49 SWVoiceIn **in[2];
50 uint8_t invol[4], inmute[2];
51
52 uint8_t diff[2], pol, ds, monomix[2], alc, mute;
53 uint8_t path[4], mpath[2], power, format;
54 const WMRate *rate;
55 uint8_t rate_vmstate;
56 int adc_hz, dac_hz, ext_adc_hz, ext_dac_hz, master;
57} WM8750State;
58
59
60static const uint8_t wm8750_vol_db_table[] = {
61 255, 227, 203, 181, 161, 143, 128, 114, 102, 90, 81, 72, 64, 57, 51, 45,
62 40, 36, 32, 29, 26, 23, 20, 18, 16, 14, 13, 11, 10, 9, 8, 7, 6, 6, 5, 5,
63 4, 4, 3, 3, 3, 2, 2
64};
65
66#define WM8750_OUTVOL_TRANSFORM(x) wm8750_vol_db_table[(0x7f - x) / 3]
67#define WM8750_INVOL_TRANSFORM(x) (x << 2)
68
69static inline void wm8750_in_load(WM8750State *s)
70{
71 if (s->idx_in + s->req_in <= sizeof(s->data_in))
72 return;
73 s->idx_in = MAX(0, (int) sizeof(s->data_in) - s->req_in);
74 AUD_read(*s->in[0], s->data_in + s->idx_in,
75 sizeof(s->data_in) - s->idx_in);
76}
77
78static inline void wm8750_out_flush(WM8750State *s)
79{
80 int sent = 0;
81 while (sent < s->idx_out)
82 sent += AUD_write(*s->out[0], s->data_out + sent, s->idx_out - sent)
83 ?: s->idx_out;
84 s->idx_out = 0;
85}
86
87static void wm8750_audio_in_cb(void *opaque, int avail_b)
88{
89 WM8750State *s = (WM8750State *) opaque;
90 s->req_in = avail_b;
91 s->data_req(s->opaque, s->req_out >> 2, avail_b >> 2);
92}
93
94static void wm8750_audio_out_cb(void *opaque, int free_b)
95{
96 WM8750State *s = (WM8750State *) opaque;
97
98 if (s->idx_out >= free_b) {
99 s->idx_out = free_b;
100 s->req_out = 0;
101 wm8750_out_flush(s);
102 } else
103 s->req_out = free_b - s->idx_out;
104
105 s->data_req(s->opaque, s->req_out >> 2, s->req_in >> 2);
106}
107
108static const WMRate wm_rate_table[] = {
109 { 256, 48000, 256, 48000 },
110 { 384, 48000, 384, 48000 },
111 { 256, 48000, 1536, 8000 },
112 { 384, 48000, 2304, 8000 },
113 { 1536, 8000, 256, 48000 },
114 { 2304, 8000, 384, 48000 },
115 { 1536, 8000, 1536, 8000 },
116 { 2304, 8000, 2304, 8000 },
117 { 1024, 12000, 1024, 12000 },
118 { 1526, 12000, 1536, 12000 },
119 { 768, 16000, 768, 16000 },
120 { 1152, 16000, 1152, 16000 },
121 { 384, 32000, 384, 32000 },
122 { 576, 32000, 576, 32000 },
123 { 128, 96000, 128, 96000 },
124 { 192, 96000, 192, 96000 },
125 { 256, 44100, 256, 44100 },
126 { 384, 44100, 384, 44100 },
127 { 256, 44100, 1408, 8018 },
128 { 384, 44100, 2112, 8018 },
129 { 1408, 8018, 256, 44100 },
130 { 2112, 8018, 384, 44100 },
131 { 1408, 8018, 1408, 8018 },
132 { 2112, 8018, 2112, 8018 },
133 { 1024, 11025, 1024, 11025 },
134 { 1536, 11025, 1536, 11025 },
135 { 512, 22050, 512, 22050 },
136 { 768, 22050, 768, 22050 },
137 { 512, 24000, 512, 24000 },
138 { 768, 24000, 768, 24000 },
139 { 128, 88200, 128, 88200 },
140 { 192, 88200, 192, 88200 },
141};
142
143static void wm8750_vol_update(WM8750State *s)
144{
145
146
147 AUD_set_volume_in(s->adc_voice[0], s->mute,
148 s->inmute[0] ? 0 : WM8750_INVOL_TRANSFORM(s->invol[0]),
149 s->inmute[1] ? 0 : WM8750_INVOL_TRANSFORM(s->invol[1]));
150 AUD_set_volume_in(s->adc_voice[1], s->mute,
151 s->inmute[0] ? 0 : WM8750_INVOL_TRANSFORM(s->invol[0]),
152 s->inmute[1] ? 0 : WM8750_INVOL_TRANSFORM(s->invol[1]));
153 AUD_set_volume_in(s->adc_voice[2], s->mute,
154 s->inmute[0] ? 0 : WM8750_INVOL_TRANSFORM(s->invol[0]),
155 s->inmute[1] ? 0 : WM8750_INVOL_TRANSFORM(s->invol[1]));
156
157
158
159
160 AUD_set_volume_out(s->dac_voice[0], s->mute,
161 s->outmute[0] ? 0 : WM8750_OUTVOL_TRANSFORM(s->outvol[4]),
162 s->outmute[1] ? 0 : WM8750_OUTVOL_TRANSFORM(s->outvol[5]));
163
164
165 AUD_set_volume_out(s->dac_voice[1], s->mute,
166 s->outmute[0] ? 0 : WM8750_OUTVOL_TRANSFORM(s->outvol[2]),
167 s->outmute[1] ? 0 : WM8750_OUTVOL_TRANSFORM(s->outvol[3]));
168
169
170 AUD_set_volume_out(s->dac_voice[2], s->mute,
171 s->outmute[0] ? 0 : WM8750_OUTVOL_TRANSFORM(s->outvol[6]),
172 s->outmute[1] ? 0 : WM8750_OUTVOL_TRANSFORM(s->outvol[6]));
173}
174
175static void wm8750_set_format(WM8750State *s)
176{
177 int i;
178 struct audsettings in_fmt;
179 struct audsettings out_fmt;
180
181 wm8750_out_flush(s);
182
183 if (s->in[0] && *s->in[0])
184 AUD_set_active_in(*s->in[0], 0);
185 if (s->out[0] && *s->out[0])
186 AUD_set_active_out(*s->out[0], 0);
187
188 for (i = 0; i < IN_PORT_N; i ++)
189 if (s->adc_voice[i]) {
190 AUD_close_in(&s->card, s->adc_voice[i]);
191 s->adc_voice[i] = NULL;
192 }
193 for (i = 0; i < OUT_PORT_N; i ++)
194 if (s->dac_voice[i]) {
195 AUD_close_out(&s->card, s->dac_voice[i]);
196 s->dac_voice[i] = NULL;
197 }
198
199 if (!s->enable)
200 return;
201
202
203 in_fmt.endianness = 0;
204 in_fmt.nchannels = 2;
205 in_fmt.freq = s->adc_hz;
206 in_fmt.fmt = AUDIO_FORMAT_S16;
207
208 s->adc_voice[0] = AUD_open_in(&s->card, s->adc_voice[0],
209 CODEC ".input1", s, wm8750_audio_in_cb, &in_fmt);
210 s->adc_voice[1] = AUD_open_in(&s->card, s->adc_voice[1],
211 CODEC ".input2", s, wm8750_audio_in_cb, &in_fmt);
212 s->adc_voice[2] = AUD_open_in(&s->card, s->adc_voice[2],
213 CODEC ".input3", s, wm8750_audio_in_cb, &in_fmt);
214
215
216 out_fmt.endianness = 0;
217 out_fmt.nchannels = 2;
218 out_fmt.freq = s->dac_hz;
219 out_fmt.fmt = AUDIO_FORMAT_S16;
220
221 s->dac_voice[0] = AUD_open_out(&s->card, s->dac_voice[0],
222 CODEC ".speaker", s, wm8750_audio_out_cb, &out_fmt);
223 s->dac_voice[1] = AUD_open_out(&s->card, s->dac_voice[1],
224 CODEC ".headphone", s, wm8750_audio_out_cb, &out_fmt);
225
226 s->dac_voice[2] = AUD_open_out(&s->card, s->dac_voice[2],
227 CODEC ".monomix", s, wm8750_audio_out_cb, &out_fmt);
228
229
230 wm8750_vol_update(s);
231
232
233
234
235
236 if (s->in[0] && *s->in[0])
237 AUD_set_active_in(*s->in[0], 1);
238 if (s->out[0] && *s->out[0])
239 AUD_set_active_out(*s->out[0], 1);
240}
241
242static void wm8750_clk_update(WM8750State *s, int ext)
243{
244 if (s->master || !s->ext_dac_hz)
245 s->dac_hz = s->rate->dac_hz;
246 else
247 s->dac_hz = s->ext_dac_hz;
248
249 if (s->master || !s->ext_adc_hz)
250 s->adc_hz = s->rate->adc_hz;
251 else
252 s->adc_hz = s->ext_adc_hz;
253
254 if (s->master || (!s->ext_dac_hz && !s->ext_adc_hz)) {
255 if (!ext)
256 wm8750_set_format(s);
257 } else {
258 if (ext)
259 wm8750_set_format(s);
260 }
261}
262
263static void wm8750_reset(I2CSlave *i2c)
264{
265 WM8750State *s = WM8750(i2c);
266
267 s->rate = &wm_rate_table[0];
268 s->enable = 0;
269 wm8750_clk_update(s, 1);
270 s->diff[0] = 0;
271 s->diff[1] = 0;
272 s->ds = 0;
273 s->alc = 0;
274 s->in[0] = &s->adc_voice[0];
275 s->invol[0] = 0x17;
276 s->invol[1] = 0x17;
277 s->invol[2] = 0xc3;
278 s->invol[3] = 0xc3;
279 s->out[0] = &s->dac_voice[0];
280 s->outvol[0] = 0xff;
281 s->outvol[1] = 0xff;
282 s->outvol[2] = 0x79;
283 s->outvol[3] = 0x79;
284 s->outvol[4] = 0x79;
285 s->outvol[5] = 0x79;
286 s->outvol[6] = 0x79;
287 s->inmute[0] = 0;
288 s->inmute[1] = 0;
289 s->outmute[0] = 0;
290 s->outmute[1] = 0;
291 s->mute = 1;
292 s->path[0] = 0;
293 s->path[1] = 0;
294 s->path[2] = 0;
295 s->path[3] = 0;
296 s->mpath[0] = 0;
297 s->mpath[1] = 0;
298 s->format = 0x0a;
299 s->idx_in = sizeof(s->data_in);
300 s->req_in = 0;
301 s->idx_out = 0;
302 s->req_out = 0;
303 wm8750_vol_update(s);
304 s->i2c_len = 0;
305}
306
307static int wm8750_event(I2CSlave *i2c, enum i2c_event event)
308{
309 WM8750State *s = WM8750(i2c);
310
311 switch (event) {
312 case I2C_START_SEND:
313 s->i2c_len = 0;
314 break;
315 case I2C_FINISH:
316#ifdef VERBOSE
317 if (s->i2c_len < 2)
318 printf("%s: message too short (%i bytes)\n",
319 __func__, s->i2c_len);
320#endif
321 break;
322 default:
323 break;
324 }
325
326 return 0;
327}
328
329#define WM8750_LINVOL 0x00
330#define WM8750_RINVOL 0x01
331#define WM8750_LOUT1V 0x02
332#define WM8750_ROUT1V 0x03
333#define WM8750_ADCDAC 0x05
334#define WM8750_IFACE 0x07
335#define WM8750_SRATE 0x08
336#define WM8750_LDAC 0x0a
337#define WM8750_RDAC 0x0b
338#define WM8750_BASS 0x0c
339#define WM8750_TREBLE 0x0d
340#define WM8750_RESET 0x0f
341#define WM8750_3D 0x10
342#define WM8750_ALC1 0x11
343#define WM8750_ALC2 0x12
344#define WM8750_ALC3 0x13
345#define WM8750_NGATE 0x14
346#define WM8750_LADC 0x15
347#define WM8750_RADC 0x16
348#define WM8750_ADCTL1 0x17
349#define WM8750_ADCTL2 0x18
350#define WM8750_PWR1 0x19
351#define WM8750_PWR2 0x1a
352#define WM8750_ADCTL3 0x1b
353#define WM8750_ADCIN 0x1f
354#define WM8750_LADCIN 0x20
355#define WM8750_RADCIN 0x21
356#define WM8750_LOUTM1 0x22
357#define WM8750_LOUTM2 0x23
358#define WM8750_ROUTM1 0x24
359#define WM8750_ROUTM2 0x25
360#define WM8750_MOUTM1 0x26
361#define WM8750_MOUTM2 0x27
362#define WM8750_LOUT2V 0x28
363#define WM8750_ROUT2V 0x29
364#define WM8750_MOUTV 0x2a
365
366static int wm8750_tx(I2CSlave *i2c, uint8_t data)
367{
368 WM8750State *s = WM8750(i2c);
369 uint8_t cmd;
370 uint16_t value;
371
372 if (s->i2c_len >= 2) {
373#ifdef VERBOSE
374 printf("%s: long message (%i bytes)\n", __func__, s->i2c_len);
375#endif
376 return 1;
377 }
378 s->i2c_data[s->i2c_len ++] = data;
379 if (s->i2c_len != 2)
380 return 0;
381
382 cmd = s->i2c_data[0] >> 1;
383 value = ((s->i2c_data[0] << 8) | s->i2c_data[1]) & 0x1ff;
384
385 switch (cmd) {
386 case WM8750_LADCIN:
387 s->diff[0] = (((value >> 6) & 3) == 3);
388 if (s->diff[0])
389 s->in[0] = &s->adc_voice[0 + s->ds * 1];
390 else
391 s->in[0] = &s->adc_voice[((value >> 6) & 3) * 1 + 0];
392 break;
393
394 case WM8750_RADCIN:
395 s->diff[1] = (((value >> 6) & 3) == 3);
396 if (s->diff[1])
397 s->in[1] = &s->adc_voice[0 + s->ds * 1];
398 else
399 s->in[1] = &s->adc_voice[((value >> 6) & 3) * 1 + 0];
400 break;
401
402 case WM8750_ADCIN:
403 s->ds = (value >> 8) & 1;
404 if (s->diff[0])
405 s->in[0] = &s->adc_voice[0 + s->ds * 1];
406 if (s->diff[1])
407 s->in[1] = &s->adc_voice[0 + s->ds * 1];
408 s->monomix[0] = (value >> 6) & 3;
409 break;
410
411 case WM8750_ADCTL1:
412 s->monomix[1] = (value >> 1) & 1;
413 break;
414
415 case WM8750_PWR1:
416 s->enable = ((value >> 6) & 7) == 3;
417 wm8750_set_format(s);
418 break;
419
420 case WM8750_LINVOL:
421 s->invol[0] = value & 0x3f;
422 s->inmute[0] = (value >> 7) & 1;
423 wm8750_vol_update(s);
424 break;
425
426 case WM8750_RINVOL:
427 s->invol[1] = value & 0x3f;
428 s->inmute[1] = (value >> 7) & 1;
429 wm8750_vol_update(s);
430 break;
431
432 case WM8750_ADCDAC:
433 s->pol = (value >> 5) & 3;
434 s->mute = (value >> 3) & 1;
435 wm8750_vol_update(s);
436 break;
437
438 case WM8750_ADCTL3:
439 break;
440
441 case WM8750_LADC:
442 s->invol[2] = value & 0xff;
443 wm8750_vol_update(s);
444 break;
445
446 case WM8750_RADC:
447 s->invol[3] = value & 0xff;
448 wm8750_vol_update(s);
449 break;
450
451 case WM8750_ALC1:
452 s->alc = (value >> 7) & 3;
453 break;
454
455 case WM8750_NGATE:
456 case WM8750_3D:
457 break;
458
459 case WM8750_LDAC:
460 s->outvol[0] = value & 0xff;
461 wm8750_vol_update(s);
462 break;
463
464 case WM8750_RDAC:
465 s->outvol[1] = value & 0xff;
466 wm8750_vol_update(s);
467 break;
468
469 case WM8750_BASS:
470 break;
471
472 case WM8750_LOUTM1:
473 s->path[0] = (value >> 8) & 1;
474
475 wm8750_vol_update(s);
476 break;
477
478 case WM8750_LOUTM2:
479 s->path[1] = (value >> 8) & 1;
480
481 wm8750_vol_update(s);
482 break;
483
484 case WM8750_ROUTM1:
485 s->path[2] = (value >> 8) & 1;
486
487 wm8750_vol_update(s);
488 break;
489
490 case WM8750_ROUTM2:
491 s->path[3] = (value >> 8) & 1;
492
493 wm8750_vol_update(s);
494 break;
495
496 case WM8750_MOUTM1:
497 s->mpath[0] = (value >> 8) & 1;
498
499 wm8750_vol_update(s);
500 break;
501
502 case WM8750_MOUTM2:
503 s->mpath[1] = (value >> 8) & 1;
504
505 wm8750_vol_update(s);
506 break;
507
508 case WM8750_LOUT1V:
509 s->outvol[2] = value & 0x7f;
510 wm8750_vol_update(s);
511 break;
512
513 case WM8750_LOUT2V:
514 s->outvol[4] = value & 0x7f;
515 wm8750_vol_update(s);
516 break;
517
518 case WM8750_ROUT1V:
519 s->outvol[3] = value & 0x7f;
520 wm8750_vol_update(s);
521 break;
522
523 case WM8750_ROUT2V:
524 s->outvol[5] = value & 0x7f;
525 wm8750_vol_update(s);
526 break;
527
528 case WM8750_MOUTV:
529 s->outvol[6] = value & 0x7f;
530 wm8750_vol_update(s);
531 break;
532
533 case WM8750_ADCTL2:
534 break;
535
536 case WM8750_PWR2:
537 s->power = value & 0x7e;
538
539 wm8750_vol_update(s);
540 break;
541
542 case WM8750_IFACE:
543 s->format = value;
544 s->master = (value >> 6) & 1;
545 wm8750_clk_update(s, s->master);
546 break;
547
548 case WM8750_SRATE:
549 s->rate = &wm_rate_table[(value >> 1) & 0x1f];
550 wm8750_clk_update(s, 0);
551 break;
552
553 case WM8750_RESET:
554 wm8750_reset(I2C_SLAVE(s));
555 break;
556
557#ifdef VERBOSE
558 default:
559 printf("%s: unknown register %02x\n", __func__, cmd);
560#endif
561 }
562
563 return 0;
564}
565
566static uint8_t wm8750_rx(I2CSlave *i2c)
567{
568 return 0x00;
569}
570
571static int wm8750_pre_save(void *opaque)
572{
573 WM8750State *s = opaque;
574
575 s->rate_vmstate = s->rate - wm_rate_table;
576
577 return 0;
578}
579
580static int wm8750_post_load(void *opaque, int version_id)
581{
582 WM8750State *s = opaque;
583
584 s->rate = &wm_rate_table[s->rate_vmstate & 0x1f];
585 return 0;
586}
587
588static const VMStateDescription vmstate_wm8750 = {
589 .name = CODEC,
590 .version_id = 0,
591 .minimum_version_id = 0,
592 .pre_save = wm8750_pre_save,
593 .post_load = wm8750_post_load,
594 .fields = (VMStateField[]) {
595 VMSTATE_UINT8_ARRAY(i2c_data, WM8750State, 2),
596 VMSTATE_INT32(i2c_len, WM8750State),
597 VMSTATE_INT32(enable, WM8750State),
598 VMSTATE_INT32(idx_in, WM8750State),
599 VMSTATE_INT32(req_in, WM8750State),
600 VMSTATE_INT32(idx_out, WM8750State),
601 VMSTATE_INT32(req_out, WM8750State),
602 VMSTATE_UINT8_ARRAY(outvol, WM8750State, 7),
603 VMSTATE_UINT8_ARRAY(outmute, WM8750State, 2),
604 VMSTATE_UINT8_ARRAY(invol, WM8750State, 4),
605 VMSTATE_UINT8_ARRAY(inmute, WM8750State, 2),
606 VMSTATE_UINT8_ARRAY(diff, WM8750State, 2),
607 VMSTATE_UINT8(pol, WM8750State),
608 VMSTATE_UINT8(ds, WM8750State),
609 VMSTATE_UINT8_ARRAY(monomix, WM8750State, 2),
610 VMSTATE_UINT8(alc, WM8750State),
611 VMSTATE_UINT8(mute, WM8750State),
612 VMSTATE_UINT8_ARRAY(path, WM8750State, 4),
613 VMSTATE_UINT8_ARRAY(mpath, WM8750State, 2),
614 VMSTATE_UINT8(format, WM8750State),
615 VMSTATE_UINT8(power, WM8750State),
616 VMSTATE_UINT8(rate_vmstate, WM8750State),
617 VMSTATE_I2C_SLAVE(parent_obj, WM8750State),
618 VMSTATE_END_OF_LIST()
619 }
620};
621
622static void wm8750_realize(DeviceState *dev, Error **errp)
623{
624 WM8750State *s = WM8750(dev);
625
626 AUD_register_card(CODEC, &s->card);
627 wm8750_reset(I2C_SLAVE(s));
628}
629
630#if 0
631static void wm8750_fini(I2CSlave *i2c)
632{
633 WM8750State *s = WM8750(i2c);
634
635 wm8750_reset(I2C_SLAVE(s));
636 AUD_remove_card(&s->card);
637 g_free(s);
638}
639#endif
640
641void wm8750_data_req_set(DeviceState *dev, data_req_cb *data_req, void *opaque)
642{
643 WM8750State *s = WM8750(dev);
644
645 s->data_req = data_req;
646 s->opaque = opaque;
647}
648
649void wm8750_dac_dat(void *opaque, uint32_t sample)
650{
651 WM8750State *s = (WM8750State *) opaque;
652
653 *(uint32_t *) &s->data_out[s->idx_out] = sample;
654 s->req_out -= 4;
655 s->idx_out += 4;
656 if (s->idx_out >= sizeof(s->data_out) || s->req_out <= 0)
657 wm8750_out_flush(s);
658}
659
660void *wm8750_dac_buffer(void *opaque, int samples)
661{
662 WM8750State *s = (WM8750State *) opaque;
663
664 void *ret = s->data_out + s->idx_out;
665
666 s->idx_out += samples << 2;
667 s->req_out -= samples << 2;
668 return ret;
669}
670
671void wm8750_dac_commit(void *opaque)
672{
673 WM8750State *s = (WM8750State *) opaque;
674
675 wm8750_out_flush(s);
676}
677
678uint32_t wm8750_adc_dat(void *opaque)
679{
680 WM8750State *s = (WM8750State *) opaque;
681 uint32_t *data;
682
683 if (s->idx_in >= sizeof(s->data_in)) {
684 wm8750_in_load(s);
685 if (s->idx_in >= sizeof(s->data_in)) {
686 return 0x80008000;
687 }
688 }
689
690 data = (uint32_t *) &s->data_in[s->idx_in];
691 s->req_in -= 4;
692 s->idx_in += 4;
693 return *data;
694}
695
696void wm8750_set_bclk_in(void *opaque, int new_hz)
697{
698 WM8750State *s = (WM8750State *) opaque;
699
700 s->ext_adc_hz = new_hz;
701 s->ext_dac_hz = new_hz;
702 wm8750_clk_update(s, 1);
703}
704
705static Property wm8750_properties[] = {
706 DEFINE_AUDIO_PROPERTIES(WM8750State, card),
707 DEFINE_PROP_END_OF_LIST(),
708};
709
710static void wm8750_class_init(ObjectClass *klass, void *data)
711{
712 DeviceClass *dc = DEVICE_CLASS(klass);
713 I2CSlaveClass *sc = I2C_SLAVE_CLASS(klass);
714
715 dc->realize = wm8750_realize;
716 sc->event = wm8750_event;
717 sc->recv = wm8750_rx;
718 sc->send = wm8750_tx;
719 dc->vmsd = &vmstate_wm8750;
720 device_class_set_props(dc, wm8750_properties);
721}
722
723static const TypeInfo wm8750_info = {
724 .name = TYPE_WM8750,
725 .parent = TYPE_I2C_SLAVE,
726 .instance_size = sizeof(WM8750State),
727 .class_init = wm8750_class_init,
728};
729
730static void wm8750_register_types(void)
731{
732 type_register_static(&wm8750_info);
733}
734
735type_init(wm8750_register_types)
736